Mathc gnuplot/Vectorielle : Quelques exemples
La géométrie de la tortue dans Wikipedia.
Préambule
modifierPrésentation
modifier- Quelques exemples .
Dessiner
modifierPetits jeux sur les pentagones
modifierN'oubliez pas les fichiers h de la librairie.
c01.c Petits jeux sur les pentagones |
---|
/* ------------------------------------ */
/* save as : c01.c */
/* ------------------------------------ */
#include "v_a.h"
#include "y_r.h"
/* ------------------------------------ */
void shape(
double **U,
double side,
int nbside,
double angle0
)
{
double i=nbside;
double shapeangle=360./nbside;
for(;i--;angle0+=shapeangle)
vo(U,angle0,side);
}
/* ------------------------------------ */
int main(void)
{
double side = 3.;
double nbside = 5.;
double angle = 0.;
double **U = G_main(-10.,10.,-10.,10.);
setup(U,-5,5);
for(angle=0; angle<360; angle+=6)
shape(U,side,nbside,angle);
setup(U,5.,5.);
for(angle=0; angle<360; angle+=12)
shape(U,side,nbside,angle);
setup(U,-5.,-5.);
for(angle=0; angle<360; angle+=36)
shape(U,side,nbside,angle);
setup(U,5.,-5.);
for(angle=0; angle<360; angle+=72)
shape(U,side,nbside,angle);
F_mR(U);
printf(" * open the file a_main.plt with Gnuplot. \n");
return 0;
}
Résultat dans gnuplot |
---|
Une feuille
modifierN'oubliez pas les fichiers h de la librairie.
c02.c Une feuille |
---|
/* ------------------------------------ */
/* save as : c02.c */
/* ------------------------------------ */
#include "v_a.h"
#include "y_r.h"
/* ------------------------------------ */
double **tree(
double **U,
double brancheangle,
double branchelength,
double branchebranche,
double step,
double angletrunc
)
{
double j=angletrunc;
double i=branchelength;
vo(U,+90.,branchelength);
for(;i>0;i-=step,j+=angletrunc)
{
vo(U, brancheangle+90., i);
vo(U, brancheangle+90., -i);
vo(U,-brancheangle+90., i);
vo(U,-brancheangle+90., -i);
vo(U, j+90., i/branchebranche);
}
return(U);
}
/* ------------------------------------ */
int main(void)
{
double **U = G_main(-40.,40.,-40.,40.);
double branchebranche = 4.;
double branchelength = 10.;
double brancheangle = -45.;
double step = .5;
setup(U,-20.,0.);
tree(U,brancheangle,branchelength,branchebranche,step,2);
setup(U,0.,0.);
tree(U,brancheangle,branchelength,branchebranche,step,4);
setup(U,20.,0.);
tree(U,brancheangle,branchelength,branchebranche,step,6);
setup(U,-20.,-40.);
tree(U,brancheangle,branchelength,branchebranche,step,8);
setup(U,0.,-40.);
tree(U,brancheangle,branchelength,branchebranche,step,10);
setup(U,20.,-40.);
tree(U,brancheangle,branchelength,branchebranche,step,12);
F_mR(U);
return 0;
}
Résultat dans gnuplot |
---|
Petit jeux sur les polygones 1
modifierN'oubliez pas les fichiers h de la librairie.
c03.c Petit jeux sur les polygones 1 |
---|
/* ------------------------------------ */
/* save as : c03.c */
/* ------------------------------------ */
#include "v_a.h"
#include "y_r.h"
/* ------------------------------------ */
void duopoly(
double **U,
double **Sides,
double **Angles,
double alpha,
int n
)
{
int i=1;
int c;
for(;i++<n;)
for(c=C1;c<Angles[C_SIZE][OF];c++)
vo(U,i*(Angles[R1][c])+alpha,Sides[R1][c]);
}
/* ------------------------------------ */
int main(void)
{
double alpha =-0;
double a[2] ={ 45., 46.};
double s[2] ={ 140., 140.};
double **U = G_main(-1000.,1000.,-1000.,1000.);
double **A = c_a_A_mR(a,I_mR(R1,C2));
double **S = c_a_A_mR(s,I_mR(R1,C2));
setup(U,-150, 350.);
duopoly(U,S,A,alpha,152);
setup(U, 800, 350.);
duopoly(U,S,A,alpha,200);
setup(U,-150,-600.);
duopoly(U,S,A,alpha,275);
setup(U, 800,-600.);
duopoly(U,S,A,alpha,400);
F_mR(U);
return 0;
}
Résultat dans gnuplot |
---|
Petit jeux sur les polygones 2
modifierN'oubliez pas les fichiers h de la librairie.
c04.c Petit jeux sur les polygones 2 |
---|
/* ------------------------------------ */
/* save as : c04.c */
/* ------------------------------------ */
#include "v_a.h"
#include "y_r.h"
/* ------------------------------------ */
void duopoly(
double **U,
double **Sides,
double **Angles,
double alpha,
int n
)
{
int i=1;
int c;
for(;i++<n;)
for(c=C1;c<Angles[C_SIZE][OF];c++)
vo(U,i*(Angles[R1][c])+alpha,Sides[R1][c]);
}
/* ------------------------------------ */
int main(void)
{
double alpha =-0;
double a[2] ={ 45., 46.};
double s[2] ={ 140., -140.};
double **U = G_main(-1000.,1000.,-1000.,1000.);
double **A = c_a_A_mR(a,I_mR(R1,C2));
double **S = c_a_A_mR(s,I_mR(R1,C2));
setup(U,-550, 450.);
duopoly(U,S,A,alpha,152);
setup(U, 500, 450.);
duopoly(U,S,A,alpha,200);
setup(U,-550,-500.);
duopoly(U,S,A,alpha,275);
setup(U, 500,-500.);
duopoly(U,S,A,alpha,400);
F_mR(U);
return 0;
}
Résultat dans gnuplot |
---|
Petit jeux sur les polygones 3
modifierN'oubliez pas les fichiers h de la librairie.
c05.c Petit jeux sur les polygones 3 |
---|
/* ------------------------------------ */
/* save as : c05.c */
/* ------------------------------------ */
#include "v_a.h"
#include "y_r.h"
/* ------------------------------------ */
void duopoly(
double **U,
double **Sides,
double **Angles,
double alpha,
int n
)
{
int a=1;
int i=1;
int c;
for(;i++<n;)
for(c=C1;c<Angles[C_SIZE][OF];c++)
if(a)
{vu(U,i*(Angles[R1][c])+alpha,Sides[R1][c]);
a=0;}
else
{vo(U,i*(Angles[R1][c])+alpha,Sides[R1][c]);
a=1;}
}
/* ------------------------------------ */
int main(void)
{
double alpha =-0;
double a[2] ={ 45., 46.};
double s[2] ={ 140., -140.};
double **U = G_main(-1000.,1000.,-1000.,1000.);
double **A = c_a_A_mR(a,I_mR(R1,C2));
double **S = c_a_A_mR(s,I_mR(R1,C2));
setup(U,-550, 450.);
duopoly(U,S,A,alpha,152);
setup(U, 500, 450.);
duopoly(U,S,A,alpha,200);
setup(U,-550,-500.);
duopoly(U,S,A,alpha,275);
setup(U, 500,-500.);
duopoly(U,S,A,alpha,400);
F_mR(U);
return 0;
}
Résultat dans gnuplot |
---|