Aller au contenu

Mathc gnuplot/Application : Quelques polygones

Un livre de Wikilivres.


Sommaire


Jeux sur les polygones

[modifier | modifier le wikicode]

N'oubliez pas les fichiers h de la librairie.

c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
#include "y_o.h"
/* ------------------------------------ */
void poly(
double **U,
double d,
double a,
double phasechange,
double n
)
{
double phase=0.;

  for(;n-->0;)
     {
      GO(U,d*cos(phase));
      TU(U,-a);
      phase+=phasechange;
     }
}
/* ------------------------------------ */
int main(void)
{
double **U = GINIT(-10.,10.,-10.,10.);

   clrscrn();

          /* poly(U, d,   a,   phasechange, n) */

   SETUP(U,0.,-8, 4  );poly(U, 1.5, 45., 1.,500.);
   SETUP(U,0., 3, 1  );poly(U, 7. , 45., 3.,100.);
   SETUP(U,0.,-1,-6.5);poly(U, 3. , 45., 6.,100.);
   SETUP(U,0., 3,-7  );poly(U, 5. , 45., 8.,500.);
   F_mR(U);

  printf("  ... load \"a_main.plt\" ... with gnuplot.\n");
  getchar(); 

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Résultat dans gnuplot
Turtles10