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
13 \includegraphics[width=
7cm
]{figures/hommage11.pdf
}
14 \caption{Une spirale conique
}
18 \begin{minipage
}{10cm
}
19 \begin{lstlisting
}[frame=tb
]
21 figureespace(-
10u,-
10u,
10u,
10u);
22 Initialisation(
200,
20,
20,
15);
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);
29 \paragraph{Exemple
2}\hfill\newline
32 \includegraphics[scale=
0.9]{figures/hommage21.pdf
}
33 \caption{La surface $z=
\dfrac{\sin(x^
2+y^
2)
}3$
}
35 \begin{lstlisting
}[frame=tb
]
39 figureespace(-
10u,-
10u,
10u,
10u);
40 Initialisation(
5000,
30,
30,
40);
42 incolor:=
0.9[gris,blanc
];
43 draw SurfZ("sin((X**
2+Y**
2)/
3)",-
5,
5,-
5,
5,
90,
120);
47 \paragraph{Exemple
3}\hfill\newline
50 \includegraphics{figures/hommage31.pdf
}
51 \caption{La surface $z=xy(x^
2-y^
2)$
}
53 \begin{lstlisting
}[frame=tb
]
55 figureespace(-
10u,-
10u,
10u,
10u);
56 Initialisation(
500,
50,
60,
40);
58 incolor:=
0.9[gris,blanc
];
59 draw SurfZ("X*Y*(X**
2-Y**
2)*
0.1",-
3,
3,-
3,
3,
30,
60);
63 \paragraph{Exemple
4}\hfill\newline
67 \includegraphics[width=
7cm
]{figures/hommage41.pdf
}
68 \caption{Un coquillage
}
72 \begin{minipage
}{10cm
}
73 \begin{lstlisting
}[frame=tb
]
75 figureespace(-
10u,-
10u,
10u,
10u);
76 Initialisation(
2000,
20,-
10,
25);
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);
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.
94 \includegraphics[width=
7cm
]{figures/hommage51.pdf
}
95 \caption{Des champignons
}
97 \begin{lstlisting
}[frame=tb
]%
98 figureespace(-
10u,-
10u,
10u,
10u);
99 Initialisation(
500,
20,
10,
10);
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))--
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)--
109 enddef;
%pour la section des champignons
114 Ferme1:=true;
%pour ne pas tenir compte des faces non vues
115 ObjetAnneau1("nbp=
18",Pp(R,h));
117 outcolor:=
0.5[rouge,blanc
];
121 ObjetAnneau2("nbp=
18",Pp(R,h));
125 outcolor:=
0.5[jaune,white
];
127 ObjetAnneau3("nbp=
18",Pp(R,h));
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.
136 \includegraphics{figures/fuseetintin1.pdf
}
137 \caption{La fusée de Tintin
}
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)))
144 transformation:=true;
147 figureespace(-
10u,-
10u,
10u,
10u);
150 fill fullcircle scaled (
2*uniformdeviate(
1)*mm) shifted((uniformdeviate(
1))
[coinbg,coinbd
]+uniformdeviate(
1)*(coinhg-coinbg)) withcolor jaune;
153 Initialisation(
500,-
50,
20,
50);
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);
165 propulsion=(
0,
4.6)--(-
0.8,
4.6)--(
0,
0);
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);
175 incolor:=
0.5[jaune,orange
];
177 ObjetAnneau2("nbp=
7",rocket1);
178 ObjetAnneau3("nbp=
7",rocket3);
180 outcolor:=
0.5[jaune,orange
];
181 ObjetAnneau10("nbp=
3",propulsion);
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);
186 ObjetAnneau4("nbp=
22",amortisseur);
190 ObjetAnneau5("nbp=
22",amortisseur);
194 ObjetAnneau6("nbp=
22",amortisseur);
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));
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));
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));
205 clip currentpicture to (fullcircle scaled
16cm);
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
}
222 \begin{minipage
}{9cm
}
223 \begin{lstlisting
}[frame=tb
]
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;";
230 figureespace(-
10u,-
10u,
10u,
10u);
231 Initialisation(
1500,
30,
20,
50);
233 Objettore1("R=
3","r=
1");
238 \paragraph{Exemple
7} Manuel a également construis une
239 image
\footnote{D'autres sont également disponibles à l'adresse
241 \url{http://melusine.eu.org/lab/bpst/pst- solides3d/tintin
}
243 le package
\texttt{pst-map
} et
\texttt{pst-solides3d
}. Il était
244 tentant alors de meler
\texttt{mp-solides
} et
\texttt{mp-geo
}.
247 \includegraphics{figures/Terrefusee1.pdf
}
248 \caption{La fusée s'éloignant de la Terre
}
250 \begin{lstlisting
}[frame=tb
]
251 %figure obtenue en modifiant un petit peu la macro
252 %originelle Mappemonde.
256 vardef mappemonde(expr longobs,latobs)=
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);
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));
266 pte4-pte3=Normal((
0,
0,
0),pte1,pte2);
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");
302 drawoptions(withcolor gris);
309 draw cercles(pte3,pte1,pte3,pte1,pte4);
312 vardef Transform(expr PT)=RotY(RotX(RotZ(PT)))
315 transformation:=true;
317 figureespace(-
10u,-
10u,
10u,
10u);
327 fill fullcircle scaled (
2*uniformdeviate(
1)*mm) shifted((uniformdeviate(
1))
[coinbg,coinbd
]+uniformdeviate(
1)*(coinhg-coinbg)) withcolor jaune;
331 Initialisation(
500,
160,
20,
50);
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);
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;";
346 ObjetAnneau1("nbp=
10",rocket2);
351 ObjetAnneau2("nbp=
7",rocket1);
352 ObjetAnneau3("nbp=
7",rocket3);
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);
359 TR:=(
0,-
15,
0)+Image((
0,-
5,
0));
360 ObjetAnneau5("nbp=
22",amortisseur);
363 TR:=(
0,-
15,
0)+Image((
0,-
5,
0));
364 ObjetAnneau6("nbp=
22",amortisseur);
365 TR:=(
0,-
15,
0)+(
0,
0,
0);
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));
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));
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));