Ajout de la rubrique divers dans exemples, 1 exemple.
[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 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.