Mobdification de Courbe en CourbeDat dans gdd.mp, ajout des variable gddXlabel et...
[mp-gdd.git] / gdd-plt.mp
1 if unknown Pi: input gdd-fct; fi;
2 if unknown repSavePict: input gdd-rep; fi;
3
4 %
5 % Courbe paramétrée
6 % ------------------------------------------------------------------------------
7 vardef Courbe(suffix fx)(suffix fy)(expr ti,tf,n) =
8     save fpas; fpas := (tf-ti)/n;
9     (fx(ti),fy(ti)) for i=1 upto n: ..(fx(ti+i*fpas),fy(ti+i*fpas)) endfor
10 enddef;
11
12 %
13 % Représentation de fonction
14 % ------------------------------------------------------------------------------
15 vardef Representation(suffix f)(expr ti,tf,n) =
16     save fpas;
17     fpas := (tf-ti)/n;
18     (ti,f(ti)) for i=1 upto n: ..(ti+i*fpas,f(ti+i*fpas)) endfor
19 enddef;
20
21 %
22 % Courbe en polaire
23 % ------------------------------------------------------------------------------
24 vardef CourbeEnPolaires(suffix r)(expr ti,tf,n) =
25     save fpas,t;
26     fpas := (tf-ti)/n;
27     r(ti)*(cos(ti),sin(ti))
28     for i=1 upto n: hide(t:=ti+i*fpas) .. r(t)*(cos(t),sin(t)) endfor
29 enddef;
30
31 %
32 % Champs de vecteurs
33 % ------------------------------------------------------------------------------
34 vardef ChampVecteurs(suffix f)(expr x,y,px,py,dx,couleur) =
35   for i = 0 upto (x - repXmin)/px:
36      for j = 0 upto (y - repYmin)/py:
37        drawarrow
38         (((0,0)--dx*unitvector((1,f(x-i*px,y-j*py))))
39                  shifted (x-i*px,y-j*py)) gddEnPlace
40                  withcolor couleur;
41      endfor
42      for j = 0 upto (repYmax - y)/py:
43        drawarrow
44         (((0,0)--dx*unitvector((1,f(x-i*px,y+j*py))))
45                  shifted (x-i*px,y+j*py)) gddEnPlace
46                  withcolor couleur;
47      endfor
48   endfor
49   for i = 0 upto (repXmax - x)/px:
50      for j = 0 upto (y - repYmin)/py:
51        drawarrow
52         (((0,0)--dx*unitvector((1,f(x+i*px,y-j*py))))
53                  shifted (x+i*px,y-j*px)) gddEnPlace
54                  withcolor couleur;
55      endfor
56      for j = 0 upto (repYmax - y)/py:
57        drawarrow
58         (((0,0)--dx*unitvector((1,f(x+i*px,y+j*py))))
59                  shifted (x+i*px,y+j*py)) gddEnPlace
60                  withcolor couleur;
61      endfor
62   endfor
63 enddef;
64
65
66 %
67 % Champs de vecteurs f R^2 -> R^2
68 % ------------------------------------------------------------------------------
69 vardef ChampVecteursDD(suffix f)(expr x,y,px,py,dx,couleur) =
70   for i = 0 upto (x - repXmin)/px:
71      for j = 0 upto (y - repYmin)/py:
72        drawarrow
73         (((0,0)--dx*unitvector(f(x-i*px,y-j*py)))
74                  shifted (x-i*px,y-j*py)) gddEnPlace
75                  withcolor couleur;
76      endfor
77      for j = 0 upto (repYmax - y)/py:
78        drawarrow
79         (((0,0)--dx*unitvector(f(x-i*px,y+j*py)))
80                  shifted (x-i*px,y+j*py)) gddEnPlace
81                  withcolor couleur;
82      endfor
83   endfor
84   for i = 0 upto (repXmax - x)/px:
85      for j = 0 upto (y - repYmin)/py:
86        drawarrow
87         (((0,0)--dx*unitvector(f(x+i*px,y-j*py)))
88                  shifted (x+i*px,y-j*px)) gddEnPlace
89                  withcolor couleur;
90      endfor
91      for j = 0 upto (repYmax - y)/py:
92        drawarrow
93         (((0,0)--dx*unitvector(f(x+i*px,y+j*py)))
94                  shifted (x+i*px,y+j*py)) gddEnPlace
95                  withcolor couleur;
96      endfor
97   endfor
98 enddef;
99
100 endinput;

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.