push artificiel
[mp-solid.git] / doc / Hommage.tex
1 \chapter{\texttt{pst-solides3d}}
2 Bien qu'il y ait de nombreux exemples empruntés à
3 \texttt{pst-solides3d} dans les parties précédentes, cette partie
4 constitue un hommage au travail des auteurs de ce package. C'est ma
5 façon de les remercier pour les conseils, les encouragements et les
6 approfondissements qu'ils m'ont apportés.
7 \par C'est également ici que l'on trouvera certaines fonctionnalités
8 avancées {\em non documentées} et/ou {\em non implantées}.
9 \paragraph{Exemple 1}\hfill\newline
10 \begin{minipage}{8cm}
11 \begin{figurefixe}
12 \centering
13 \includegraphics[width=7cm]{figures/hommage11.pdf}
14 \caption{Une spirale conique}
15 \end{figurefixe}
16 \end{minipage}
17 \hfill
18 \begin{minipage}{10cm}
19 \begin{lstlisting}[frame=tb]
20 %1'9"
21 figureespace(-10u,-10u,10u,10u);
22 Initialisation(200,20,20,15);
23 arcenciel:=true;
24 incolor:=gris;
25 draw Tuben("(0.5*t*sin(0.707)*cos(t),0.5*sin(0.707)*t*sin(t),-0.5*t*cos(0.707))","(0.5*sin(0.707)*(cos(t)-t*sin(t)),0.5*sin(0.707)*(sin(t)+t*cos(t)),-0.5*cos(0.707))",0.4,-25.4,508,0.1);
26 finespace;
27 \end{lstlisting}
28 \end{minipage}
29 \paragraph{Exemple 2}\hfill\newline
30 \begin{figure}[!ht]
31 \centering
32 \includegraphics[scale=0.9]{figures/hommage21.pdf}
33 \caption{La surface $z=\dfrac{\sin(x^2+y^2)}3$}
34 \end{figure}
35 \begin{lstlisting}[frame=tb]
36 satu:=1;
37
38 %1'9"
39 figureespace(-10u,-10u,10u,10u);
40 Initialisation(5000,30,30,40);
41 arcenciel:=true;
42 incolor:=0.9[gris,blanc];
43 draw SurfZ("sin((X**2+Y**2)/3)",-5,5,-5,5,90,120);
44 TraceAxesD(4,3,3);
45 finespace;
46 \end{lstlisting}
47 \paragraph{Exemple 3}\hfill\newline
48 \begin{figure}[!ht]
49 \centering
50 \includegraphics{figures/hommage31.pdf}
51 \caption{La surface $z=xy(x^2-y^2)$}
52 \end{figure}
53 \begin{lstlisting}[frame=tb]
54 %1"
55 figureespace(-10u,-10u,10u,10u);
56 Initialisation(500,50,60,40);
57 arcenciel:=true;
58 incolor:=0.9[gris,blanc];
59 draw SurfZ("X*Y*(X**2-Y**2)*0.1",-3,3,-3,3,30,60);
60 TraceAxesD(3,3,5);
61 finespace;
62 \end{lstlisting}
63 \paragraph{Exemple 4}\hfill\newline
64 \begin{minipage}{8cm}
65 \begin{figurefixe}
66 \centering
67 \includegraphics[width=7cm]{figures/hommage41.pdf}
68 \caption{Un coquillage}
69 \end{figurefixe}
70 \end{minipage}
71 \hfill
72 \begin{minipage}{10cm}
73 \begin{lstlisting}[frame=tb]
74 %2"
75 figureespace(-10u,-10u,10u,10u);
76 Initialisation(2000,20,-10,25);
77 arcenciel:=true;
78 incolor:=0.5[gris,white];
79 draw Sparam("(1.21**v*(sin(u)*cos(u)),1.21**v*(sin(u)**2*sin(v)),1.21**v*(sin(u)**2*cos(v)))",pi/24,11*pi/12,pi/24,0,10*pi/4,pi/24);
80 TraceAxesD(8,5,5);
81 finespace;
82 \end{lstlisting}
83 \end{minipage}
84 \paragraph{Exemple 5} Cet exemple nous permet d'utiliser le paramètre
85 \param{\verb!Ferme1!} qui indique si le solide \no1 est \og fermé\fg
86 (c'est-à-dire sans creux visibles) ou non (c'est-à-dire avec des creux
87 visibles ou si l'on souhaite voir l'intérieur du solide). L'intérêt
88 réside dans une diminution du nombre de faces à traiter; ce qui
89 contribue à un meilleur temps de compilation.\\Ici, les
90 paramètres \param{\verb!Ferme1!}\ldots sont tous à \texttt{true} : en
91 effet, on ne souhaite pas voir l'intérieur des champignons.
92 \begin{figure}
93 \centering
94 \includegraphics[width=7cm]{figures/hommage51.pdf}
95 \caption{Des champignons}
96 \end{figure}
97 \begin{lstlisting}[frame=tb]%
98 figureespace(-10u,-10u,10u,10u);
99 Initialisation(500,20,10,10);
100
101 vardef Pp(expr R,h)=(0,0)--
102 for k=-33 step 10 until 43:
103 (cosd(k)*0.5*h-0.2*h,0.3*h+0.5*h*sind(k))--
104 endfor
105 for l=0 step 15 until 90:
106 (0.8*R*cosd(l)+0.2*R,0.8*R*sind(l)+0.6*h)--
107 endfor
108 (0,h)
109 enddef;%pour la section des champignons
110
111 outcolor:=blanc;
112 nb:=30;subh:=15;
113 h=10;R=5;
114 Ferme1:=true;%pour ne pas tenir compte des faces non vues
115 ObjetAnneau1("nbp=18",Pp(R,h));
116 angx:=-20;
117 outcolor:=0.5[rouge,blanc];
118 TR:=(-4,2.5,0);
119 h:=5;R:=2.5;
120 Ferme2:=true;
121 ObjetAnneau2("nbp=18",Pp(R,h));
122 angx:=30;
123 TR:=(-4,-4,0);
124 h:=4;R:=2;
125 outcolor:=0.5[jaune,white];
126 Ferme3:=true;
127 ObjetAnneau3("nbp=18",Pp(R,h));
128 nbobj:=3;
129 DessineFusion;
130 finespace;
131 \end{lstlisting}
132 \paragraph{Exemple 6} Manuel Luque a proposé un
133 document\footnote{\url{http://melusine.eu.org/syracuse/mluque/solides3d2007/fusee_tintin/objectif_fusee.pdf}} sur la fusée lunaire utilisée par Tintin dans les deux tomes \og Objetif Lune\fg\ et \og On a marché sur la Lune\fg. J'ai donc repris comme base son travail.
134 \begin{figure}[!ht]
135 \centering
136 \includegraphics{figures/fuseetintin1.pdf}
137 \caption{La fusée de Tintin}
138 \end{figure}
139 \begin{lstlisting}[frame=tb]%
140 %Il est nécessaire de redéfinir l'ordre des rotations.
141 vardef Transform(expr PT)=RotX(RotY(RotZ(PT)))
142 enddef;
143
144 transformation:=true;
145
146 %30"
147 figureespace(-10u,-10u,10u,10u);
148 fill feuillet;
149 for k=1 upto 100:
150 fill fullcircle scaled (2*uniformdeviate(1)*mm) shifted((uniformdeviate(1))[coinbg,coinbd]+uniformdeviate(1)*(coinhg-coinbg)) withcolor jaune;
151 endfor;
152
153 Initialisation(500,-50,20,50);
154 unit:=0.2;
155 traits:=false;
156 angx:=-80;
157 angy:=20;
158 outcolor:=rouge;
159 path rocket[];
160 rocket1=(0,4.6)--(-0.8,4.6)--(-0.85,5.6)--(-0.95,6.6)--(-1.05,7.6)--(-1.1,8.6)--(-1.2,9.6);
161 rocket2=(-1.2,9.6)--(-1.25,10.6)--(-1.3,11.6)--(-1.35,12.6)--(-1.4,13.6)--(-1.4,14.6)--(-1.375,15.6)--(-1.27,16.6)--(-1.2,17.6)--(-1.05,18.6);
162 rocket3=(-1.05,18.6)--(-0.85,19.6)--(-0.65,20.6)--(-0.35,21.6)--(-0.1,22.2)--(-0.1,23.75)--(0,23.75);
163 subh:=24;
164 path propulsion;
165 propulsion=(0,4.6)--(-0.8,4.6)--(0,0);
166 perso1:=true;
167 Ferme1:=false;
168 string couleurperso;
169 couleurperso="if ((tapj mod 48)=0) or ((tapj mod 48)=1) or ((tapj mod 48)=2) or ((tapj mod 48)=6) or ((tapj mod 48)=7) or ((tapj mod 48)=8) or ((tapj mod 48)=12) or ((tapj mod 48)=13) or ((tapj mod 48)=14) or ((tapj mod 48)=18) or ((tapj mod 48)=19) or ((tapj mod 48)=20) or ((tapj mod 48)=27) or ((tapj mod 48)=28) or ((tapj mod 48)=29) or ((tapj mod 48)=33) or ((tapj mod 48)=34) or ((tapj mod 48)=35) or ((tapj mod 48)=39) or ((tapj mod 48)=40) or ((tapj mod 48)=41) or ((tapj mod 48)=45) or ((tapj mod 48)=46) or ((tapj mod 48)=47):red else: white fi;";
170 ObjetAnneau1("nbp=10",rocket2);
171 outcolor:=rouge;
172 for k=3 upto 6:
173 Ferme[k]:=true;
174 endfor;
175 incolor:=0.5[jaune,orange];
176 Ferme2:=false;
177 ObjetAnneau2("nbp=7",rocket1);
178 ObjetAnneau3("nbp=7",rocket3);
179 Ferme10:=true;
180 outcolor:=0.5[jaune,orange];
181 ObjetAnneau10("nbp=3",propulsion);
182 outcolor:=rouge;
183 path amortisseur;
184 amortisseur=for k=-90 step 10 until 0:(cosd(k),sind(k)+1)--endfor for k=0 step 2 until 22:(cosd(k)*11.78-10.78,11.78*sind(k)+1)-- endfor (0,5.75);
185 TR:=Image((0,-5,0));
186 ObjetAnneau4("nbp=22",amortisseur);
187 angz:=120;
188 TR:=(0,0,0);
189 TR:=Image((0,-5,0));
190 ObjetAnneau5("nbp=22",amortisseur);
191 angz:=-120;
192 TR:=(0,0,0);
193 TR:=Image((0,-5,0));
194 ObjetAnneau6("nbp=22",amortisseur);
195 TR:=(0,0,0);
196 angz:=0;
197 subh:=1;
198 ObjetBiface7((0,-0.8,4.6),(0,-0.85,5.6),(0,-0.95,6.6),(0,-1.05,7.6),(0,-1.1,8.6),(0,-1.2,9.6),(0,-2,9.2),(0,-3,8.3),(0,-4,7.2),(0,-5,5.75),(0,-4.5765,4.6402),(0,-4.35,3.8498),(0,-4.1789,3.0456),(0,-4.0645,2.2313),(0,-4.0072,1.4111),(0,-4,1),(0,-3.2,2.2),(0,-2.5,3),(0,-1.6,4));
199 angz:=120;
200 ObjetBiface8((0,-0.8,4.6),(0,-0.85,5.6),(0,-0.95,6.6),(0,-1.05,7.6),(0,-1.1,8.6),(0,-1.2,9.6),(0,-2,9.2),(0,-3,8.3),(0,-4,7.2),(0,-5,5.75),(0,-4.5765,4.6402),(0,-4.35,3.8498),(0,-4.1789,3.0456),(0,-4.0645,2.2313),(0,-4.0072,1.4111),(0,-4,1),(0,-3.2,2.2),(0,-2.5,3),(0,-1.6,4));
201 angz:=-120;
202 ObjetBiface9((0,-0.8,4.6),(0,-0.85,5.6),(0,-0.95,6.6),(0,-1.05,7.6),(0,-1.1,8.6),(0,-1.2,9.6),(0,-2,9.2),(0,-3,8.3),(0,-4,7.2),(0,-5,5.75),(0,-4.5765,4.6402),(0,-4.35,3.8498),(0,-4.1789,3.0456),(0,-4.0645,2.2313),(0,-4.0072,1.4111),(0,-4,1),(0,-3.2,2.2),(0,-2.5,3),(0,-1.6,4));
203 nbobj:=10;
204 DessineFusion;
205 clip currentpicture to (fullcircle scaled 16cm);
206 finespace;
207 end
208 \end{lstlisting}
209 On voit ici apparaître les paramètres \param{\verb!perso!}. Ils ont
210 été spécialement crées pour cette fusée. En effet, le principal
211 problème pour définir cette fusée est l'alternance des couleurs
212 blanche et rouge sur le corps de la fusée. Aussi à l'aide de ces
213 paramètres, on peut faire adopter un style spécial à un objet. Par
214 contre, il existe une {\em contrainte} : la définition de ce style
215 spécial doit se faire par le \texttt{string}
216 \param{\verb!couleurperso!}.
217 \par Voici un autre exemple\par
218 \begin{minipage}{8cm}
219 \includegraphics[width=8cm]{figures/torecolore1.pdf}
220 \end{minipage}
221 \hfill
222 \begin{minipage}{9cm}
223 \begin{lstlisting}[frame=tb]
224 perso1:=true;
225 couleurperso:="if ((tapj div subh) mod 3)=0:if (tapj mod 3)=0: rouge elseif (tapj mod 3)=1: noir else: bleu fi elseif ((tapj div subh) mod 3)=1:if (tapj mod 3)=1: rouge elseif (tapj mod 3)=2: noir else: bleu fi elseif ((tapj div subh) mod 3)=2:if (tapj mod 3)=2: rouge elseif (tapj mod 3)=0: noir else: bleu fi fi;";
226
227 nb:=12;
228 subh:=18;
229
230 figureespace(-10u,-10u,10u,10u);
231 Initialisation(1500,30,20,50);
232 angy:=25;angz:=-20;
233 Objettore1("R=3","r=1");
234 AffichageObjet1;
235 finespace;
236 \end{lstlisting}
237 \end{minipage}
238 \paragraph{Exemple 7} Manuel a également construis une
239 image\footnote{D'autres sont également disponibles à l'adresse
240 \begin{center}
241 \url{http://melusine.eu.org/lab/bpst/pst- solides3d/tintin}
242 \end{center}} melant
243 le package \texttt{pst-map} et \texttt{pst-solides3d}. Il était
244 tentant alors de meler \texttt{mp-solides} et \texttt{mp-geo}.
245 \begin{figure}[!ht]
246 \centering
247 \includegraphics{figures/Terrefusee1.pdf}
248 \caption{La fusée s'éloignant de la Terre}
249 \end{figure}
250 \begin{lstlisting}[frame=tb]
251 %figure obtenue en modifiant un petit peu la macro
252 %originelle Mappemonde.
253 input mp-geo
254 input mp-solid;
255
256 vardef mappemonde(expr longobs,latobs)=
257 projection:="non";
258 Initialisation(5,longobs,latobs,500);
259 numeric phim,phip,phii;%phi moins -- phi plus - phi intermediaire
260 phim=Phi+arcsind(rayon/Rho)-90;
261 phip=Phi+90-arcsind(rayon/Rho);
262 color pte[];
263 pte1=rayon*(cosd(phim)*cosd(Theta),cosd(phim)*sind(Theta),sind(phim));
264 pte2=rayon*(cosd(phip)*cosd(Theta),cosd(phip)*sind(Theta),sind(phip));
265 pte3=1/2[pte1,pte2];
266 pte4-pte3=Normal((0,0,0),pte1,pte2);
267 if (Phi>90):
268 phip:=180-phip;
269 phii:=180-phim;
270 phim:=phip;
271 phip:=phii;
272 fi;
273 if (Phi<-90):
274 phip:=-180-phip;
275 phii:=-180-phim;
276 phim:=phip;
277 phip:=phii;
278 fi;
279 fill cercles(pte3,pte1,pte3,pte1,pte4) withcolor ciel;
280 Lecture("Cameriquesud.dat");
281 Lecture("Ccaraibes.dat");
282 Lecture("Cameriquecentrale.dat");
283 Lecture("Cameriquenord.dat");
284 Lecture("Casie.dat");
285 Lecture("Ceurope.dat");
286 Lecture("Cafrique.dat");
287 if volcans=true:
288 Lecturevolcans;
289 fi;
290 if lacs=true:
291 Lecturelacs;
292 Lecturelacssup;
293 fi;
294 Lectureiles;
295 if capitales=true:
296 Lecturecapitales;
297 fi;
298 if fleuves=true:
299 Lecturerivieres;
300 fi;
301 if maillage=true:
302 drawoptions(withcolor gris);
303 MaillageSphere;
304 drawoptions();
305 fi;
306 if maille=true:
307 Maille;
308 fi;
309 draw cercles(pte3,pte1,pte3,pte1,pte4);
310 enddef;
311
312 vardef Transform(expr PT)=RotY(RotX(RotZ(PT)))
313 enddef;
314
315 transformation:=true;
316
317 figureespace(-10u,-10u,10u,10u);
318 picture terre;
319 fleuves:=false;
320 lacs:=false;
321 capitales:=false;
322 terre=image(
323 mappemonde(80,20);
324 );
325 fill feuillet;
326 for k=1 upto 100:
327 fill fullcircle scaled (2*uniformdeviate(1)*mm) shifted((uniformdeviate(1))[coinbg,coinbd]+uniformdeviate(1)*(coinhg-coinbg)) withcolor jaune;
328 endfor;
329 draw terre;
330
331 Initialisation(500,160,20,50);
332 unit:=0.2;
333 traits:=false;
334 angy:=-60;
335 outcolor:=rouge;
336 path rocket[];
337 rocket1=(0,4.6)--(-0.8,4.6)--(-0.85,5.6)--(-0.95,6.6)--(-1.05,7.6)--(-1.1,8.6)--(-1.2,9.6);
338 rocket2=(-1.2,9.6)--(-1.25,10.6)--(-1.3,11.6)--(-1.35,12.6)--(-1.4,13.6)--(-1.4,14.6)--(-1.375,15.6)--(-1.27,16.6)--(-1.2,17.6)--(-1.05,18.6);
339 rocket3=(-1.05,18.6)--(-0.85,19.6)--(-0.65,20.6)--(-0.35,21.6)--(-0.1,22.2)--(-0.1,23.75)--(0,23.75);
340 subh:=24;
341 perso1:=true;
342 Ferme1:=false;
343 string couleurperso;
344 couleurperso="if ((tapj mod 48)=0) or ((tapj mod 48)=1) or ((tapj mod 48)=2) or ((tapj mod 48)=6) or ((tapj mod 48)=7) or ((tapj mod 48)=8) or ((tapj mod 48)=12) or ((tapj mod 48)=13) or ((tapj mod 48)=14) or ((tapj mod 48)=18) or ((tapj mod 48)=19) or ((tapj mod 48)=20) or ((tapj mod 48)=27) or ((tapj mod 48)=28) or ((tapj mod 48)=29) or ((tapj mod 48)=33) or ((tapj mod 48)=34) or ((tapj mod 48)=35) or ((tapj mod 48)=39) or ((tapj mod 48)=40) or ((tapj mod 48)=41) or ((tapj mod 48)=45) or ((tapj mod 48)=46) or ((tapj mod 48)=47):red else: white fi;";
345 TR:=(0,-15,0);
346 ObjetAnneau1("nbp=10",rocket2);
347 outcolor:=rouge;
348 for k=2 upto 6:
349 Ferme[k]:=true;
350 endfor;
351 ObjetAnneau2("nbp=7",rocket1);
352 ObjetAnneau3("nbp=7",rocket3);
353 path amortisseur;
354 amortisseur=for k=-90 step 10 until 0:(cosd(k),sind(k)+1)--endfor for k=0 step 2 until 22:(cosd(k)*11.78-10.78,11.78*sind(k)+1)-- endfor (0,5.75);
355 TR:=(0,-15,0)+(0,-5,0);
356 ObjetAnneau4("nbp=22",amortisseur);
357 angz:=150;
358 TR:=(0,0,0);
359 TR:=(0,-15,0)+Image((0,-5,0));
360 ObjetAnneau5("nbp=22",amortisseur);
361 angz:=-90;
362 TR:=(0,0,0);
363 TR:=(0,-15,0)+Image((0,-5,0));
364 ObjetAnneau6("nbp=22",amortisseur);
365 TR:=(0,-15,0)+(0,0,0);
366 angz:=0;
367 subh:=1;
368 ObjetBiface7((0,-0.8,4.6),(0,-0.85,5.6),(0,-0.95,6.6),(0,-1.05,7.6),(0,-1.1,8.6),(0,-1.2,9.6),(0,-2,9.2),(0,-3,8.3),(0,-4,7.2),(0,-5,5.75),(0,-4.5765,4.6402),(0,-4.35,3.8498),(0,-4.1789,3.0456),(0,-4.0645,2.2313),(0,-4.0072,1.4111),(0,-4,1),(0,-3.2,2.2),(0,-2.5,3),(0,-1.6,4));
369 angz:=150;
370 ObjetBiface8((0,-0.8,4.6),(0,-0.85,5.6),(0,-0.95,6.6),(0,-1.05,7.6),(0,-1.1,8.6),(0,-1.2,9.6),(0,-2,9.2),(0,-3,8.3),(0,-4,7.2),(0,-5,5.75),(0,-4.5765,4.6402),(0,-4.35,3.8498),(0,-4.1789,3.0456),(0,-4.0645,2.2313),(0,-4.0072,1.4111),(0,-4,1),(0,-3.2,2.2),(0,-2.5,3),(0,-1.6,4));
371 angz:=-90;
372 ObjetBiface9((0,-0.8,4.6),(0,-0.85,5.6),(0,-0.95,6.6),(0,-1.05,7.6),(0,-1.1,8.6),(0,-1.2,9.6),(0,-2,9.2),(0,-3,8.3),(0,-4,7.2),(0,-5,5.75),(0,-4.5765,4.6402),(0,-4.35,3.8498),(0,-4.1789,3.0456),(0,-4.0645,2.2313),(0,-4.0072,1.4111),(0,-4,1),(0,-3.2,2.2),(0,-2.5,3),(0,-1.6,4));
373 nbobj:=9;
374 DessineFusion;
375 finespace;
376 end
377 \end{lstlisting}

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.