Utilisateurs de Perl à Paris

À propos de la censure et à propos des marées

Un historique de toutes nos réunions


Retour au compte-rendu

--[[
     Construction des dessins illustrant le mécanisme des marées
     Building a few drawings for the explanation of tides
     Copyright (C) 2018 Jean Forget

     This program is distributed under the same terms as Perl 5.16.3:
     GNU Public License version 1 or later and Perl Artistic License.

    Here is the summary of GPL:

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 1, or (at your option)
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software Foundation,
    Inc., https://www.fsf.org/.
]]

local substr = string.sub;
local floor  = math.floor;
local sin    = math.sin;
local pi     = math.pi;

function battement(amp1, puls1, amp2, puls2)

  tex.print("\\begin{mplibcode}\n");
  tex.print("beginfig(1);\n");

  local dx = 0.01;
  local echelle_x = 30;

  tex.print("draw (0,0)");
  for x = dx, 4 * pi, dx  do
     tex.print("..(" .. (x * echelle_x) .. "," .. (amp1 * sin(puls1 * x)) .. ")");
  end;
  tex.print(";\n");

  local decalage = -1.2 * (amp1 + amp2);
  tex.print("draw (0," .. decalage .. ")");
  for x = dx, 4 * pi, dx  do
     tex.print("..(" .. (x * echelle_x) .. "," .. (decalage + amp2 * sin(puls2 * x)) .. ")");
  end;
  tex.print(";\n");

  local decalage = -1.2 * (2 * amp1 + 3 * amp2);
  tex.print("draw (0," .. decalage .. ")");
  for x = dx, 4 * pi, dx  do
     tex.print("..(" .. (x * echelle_x) .. "," .. (decalage + amp1 * sin(puls1 * x) + amp2 * sin(puls2 * x)) .. ")");
  end;
  tex.print(";\n");

  tex.print("endfig;\n");
  tex.print("\\end{mplibcode}\n");
  tex.print("\\eject\n");
end



HTML 5 - CSS v3 Mongueurs de Paris, le 16 octobre 2018 Copyright © The Paris Perl Mongers, 1999-2024