Réinitialisation du projet
[mp-solid.git] / doc / figures / hsv.mp
1 input mp-solid
2
3 vardef grillexy(expr aa,bb,cc,dd)=
4   save _grillexy;
5   picture _grillexy;
6   color Fc[][];color G[][];
7   for l=aa upto bb:
8     for k=cc upto dd:
9       G[l][k]=(k,l,0);
10     endfor;
11   endfor;
12   apj:=0;
13   for l=aa upto (bb-1):
14     for k=cc upto (dd-1):
15       apj:=apj+1;
16       cpt[apj]:=apj;
17       Fc[apj][1]:=G[l][k];
18       Fc[apj][2]:=G[l][k+1];
19       Fc[apj][3]:=G[l+1][k+1];
20       Fc[apj][4]:=G[l+1][k];
21       Fc[apj][5]:=(Fc[apj][1]+Fc[apj][2]+Fc[apj][3]+Fc[apj][4])/4;
22       ALT[apj]:=-Zpart(GCoord(Fc[apj][1]));
23     endfor;
24   endfor;
25   QS(1,apj);
26   _grillexy=image(
27     for k=1 upto apj:
28       fill for l=1 upto 4:
29         Projette(Fc[cpt[k]][l])--
30       endfor
31       cycle withcolor if arcenciel: Hsvtorgb(((k/apj)[0*360,1*360],0.5,0.5))
32         else: couleur fi;
33       draw for l=1 upto 4:
34         Projette(Fc[cpt[k]][l])--
35       endfor
36       cycle withpen pencircle scaled0.25bp;
37     endfor;
38     );
39   _grillexy
40 enddef;
41
42 vardef grillexz(expr aa,bb,cc,dd)=
43   save _grillexz;
44   picture _grillexz;
45   color Fc[][];color G[][];
46   for l=aa upto bb:
47     for k=cc upto dd:
48       G[l][k]=(k/10,0,l/10);
49     endfor;
50   endfor;
51   apj:=0;
52   for l=aa upto (bb-1):
53     for k=cc upto (dd-1):
54       apj:=apj+1;
55       cpt[apj]:=apj;
56       Fc[apj][1]:=G[l][k];
57       Fc[apj][2]:=G[l][k+1];
58       Fc[apj][3]:=G[l+1][k+1];
59       Fc[apj][4]:=G[l+1][k];
60       Fc[apj][5]:=(Fc[apj][1]+Fc[apj][2]+Fc[apj][3]+Fc[apj][4])/4;
61       ALT[apj]:=-Zpart(GCoord(Fc[apj][1]));
62     endfor;
63   endfor;
64   QS(1,apj);
65   _grillexz=image(
66     for k=1 upto apj:
67       fill for l=1 upto 4:
68         Projette(Fc[cpt[k]][l])--
69       endfor
70       cycle withcolor if arcenciel: Hsvtorgb((180,(cpt[k]/apj)[0,1],(cpt[k]/apj)[0,1]))
71         else: couleur fi;
72     endfor;
73     );
74   _grillexz
75 enddef;
76
77 vardef grilleyz(expr aa,bb,cc,dd)=
78   save _grilleyz;
79   picture _grilleyz;
80   color Fc[][];color G[][];
81   for l=aa upto bb:
82     for k=cc upto dd:
83       G[l][k]=(0,k/10,l/10);
84     endfor;
85   endfor;
86   apj:=0;
87   for l=aa upto (bb-1):
88     for k=cc upto (dd-1):
89       apj:=apj+1;
90       cpt[apj]:=apj;
91       Fc[apj][1]:=G[l][k];
92       Fc[apj][2]:=G[l][k+1];
93       Fc[apj][3]:=G[l+1][k+1];
94       Fc[apj][4]:=G[l+1][k];
95       Fc[apj][5]:=(Fc[apj][1]+Fc[apj][2]+Fc[apj][3]+Fc[apj][4])/4;
96       ALT[apj]:=-Zpart(GCoord(Fc[apj][1]));
97     endfor;
98   endfor;
99   QS(1,apj);
100   _grilleyz=image(
101     for k=1 upto apj:
102       fill for l=1 upto 4:
103         Projette(Fc[cpt[k]][l])--
104       endfor
105       cycle withcolor if arcenciel: Hsvtorgb((120,(cpt[k]/apj)[0,1],(cpt[k]/apj)[0,1]))
106         else: couleur fi;
107     endfor;
108     );
109   _grilleyz
110 enddef;
111
112 vardef grillecirc(expr aa,bb)=
113   save _grillecirc;
114   picture _grillecirc;
115   color Fc[][];color G[][];
116   for l=aa step 5 until bb:%upto bb:
117     for k=0 upto 10:
118       G[l][k]=((k/10)*3*cosd(l),(k/10)*3*sind(-l),2);
119     endfor;
120   endfor;
121   apj:=0;
122   for l=aa step 5 until (bb-5):
123     for k=0 upto 9:
124       apj:=apj+1;
125       cpt[apj]:=apj;
126       Fc[apj][1]:=G[l][k];
127       Fc[apj][2]:=G[l][k+1];
128       Fc[apj][3]:=G[l+5][k+1];
129       Fc[apj][4]:=G[l+5][k];
130       Fc[apj][5]:=(Fc[apj][1]+Fc[apj][2]+Fc[apj][3]+Fc[apj][4])/4;
131       ALT[apj]:=-Zpart(GCoord(Fc[apj][1]));
132     endfor;
133   endfor;
134   QS(1,apj);
135   _grillecirc=image(
136     for k=1 upto apj:
137       fill for l=1 upto 4:
138         Projette(Fc[cpt[k]][l])--
139       endfor
140       cycle withcolor if arcenciel: Hsvtorgb((aa+180,(cpt[k]/apj)[0,1],1))
141         else: couleur fi;
142     endfor;
143     );
144   _grillecirc
145 enddef;
146
147 vardef tranche(expr aa,bb)=
148   save _tranche;
149   picture _tranche;
150   color Fc[][];color G[][];
151   for l=aa step 5 until bb:
152     for k=0 upto 10:
153       G[l][k]=(3*cosd(l),3*sind(-l),2*k/10);
154     endfor;
155   endfor;
156   apj:=0;
157   for l=aa step 5 until (bb-5):
158     for k=0 upto 9:
159       apj:=apj+1;
160       cpt[apj]:=apj;
161       Fc[apj][1]:=G[l][k];
162       Fc[apj][2]:=G[l][k+1];
163       Fc[apj][3]:=G[l+5][k+1];
164       Fc[apj][4]:=G[l+5][k];
165       Fc[apj][5]:=(Fc[apj][1]+Fc[apj][2]+Fc[apj][3]+Fc[apj][4])/4;
166       ALT[apj]:=-Zpart(GCoord(Fc[apj][1]));
167     endfor;
168   endfor;
169   QS(1,apj);
170   _tranche=image(
171     for k=1 upto apj:
172       fill for l=1 upto 4:
173         Projette(Fc[cpt[k]][l])--
174       endfor
175       cycle withcolor if arcenciel: Hsvtorgb((aa+180,1,(cpt[k]/apj)[0,1]))
176         else: couleur fi;
177     endfor;
178     );
179   _tranche
180 enddef;
181
182 figureespace(-10u,-10u,10u,10u);
183 Initialisation(500,45,20,50);
184 arcenciel:=true;
185 for k=90 step 5 until 265:
186   draw tranche(k,k+5);
187 endfor;
188 for k=0 step 5 until 40:
189   draw tranche(k,k+5);
190 endfor;
191 draw grillexz(0,20,0,30);
192 draw grilleyz(0,20,0,30);
193 for k=0 step 5 until 265:
194   draw grillecirc(k,k+5);
195 endfor;
196 drawarrow Projette((0,0,1))--Projette((0,3,1)) withpen pencircle scaled 2bp;
197 label.top(btex Saturation etex rotated(angle(Projette((0,3,1))-Projette((0,0,1)))),Projette((0,1.5,1)));
198 drawarrow Projette((3.2*cosd(240),3.2*sind(-240),0))--Projette((3.2*cosd(240),3.2*sind(-240),2)) withpen pencircle scaled 2bp;
199 label.rt(btex Valeur etex rotated(angle(Projette((3.2*cosd(240),3.2*sind(-240),0))-Projette((3.2*cosd(240),3.2*sind(-240),2)))),Projette((3.2*cosd(240),3.2*sind(-240),1)));
200 drawarrow Projette((3.2*cosd(-30),3.2*sind(30),1.8))..Projette(((3.2*cosd(10),3.2*sind(-10),1.8)))..Projette(((3.2*cosd(20),3.2*sind(-20),1.8)))..Projette(((3.2*cosd(30),3.2*sind(-30),1.8))) withpen pencircle scaled 2bp;
201 label.bot(btex Teinte etex rotated angle(Projette(((3.2*cosd(-30),3.2*sind(30),1.8)))-Projette((3.2*cosd(30),3.2*sind(-30),1.8))),Projette(((3.2*cosd(0),3.2*sind(0),1.8))));
202 finespace;
203 end

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.