Initialisation du projet pst-solides3d.git (SVN revision 142)
[pst-solides3d.git] / doc / .svn / text-base / par-fusionjps.tex.svn-base
1 \def\grille{% quadrillage du plan Oxy
2     \psPoint(-5,-5,0){S1}
3     \psPoint(-5,5,0){S2}
4     \psPoint(5,5,0){S3}
5     \psPoint(5,-5,0){S4}
6 \pspolygon*[linecolor=gray!20](S1)(S2)(S3)(S4)
7 \multido{\ix=-5+1}{11}{%
8     \psPoint(\ix\space,-5,0){A}
9     \psPoint(\ix\space,5,0){B}
10     \psline(A)(B)}
11 \multido{\iy=-5+1}{11}{%
12     \psPoint(-5,\iy\space,0){A}
13     \psPoint(5,\iy\space,0){B}
14     \psline(A)(B)}
15     \psPoint(0,0,0){O}
16     \psPoint(5,0,0){X}
17     \psPoint(0,5,0){Y}
18     \psPoint(0,0,8){Z}
19     \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(X)
20     \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(Y)
21     \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(Z)
22     \uput[r](X){\textcolor{blue}{$x$}}\uput[u](Y){\textcolor{blue}{$y$}}%
23     \uput[r](Z){\textcolor{blue}{$z$}}\uput[u](O){\textcolor{blue}{$O$}}}
24
25
26 \section{Fusion avec le code jps}
27
28 On peut également opérer la fusion de solides en passant directement
29 par le code jps.
30 Le calcul des parties cachées est effectué par les routines du code
31 \texttt{PostScript} du fichier \texttt{solides.pro}, mais les lignes
32 de code sont ``encapsulées'' dans un environnement \texttt{pspicture}
33 grâce à la commande \verb+\codejps{code ps}+.
34
35 \subsection{Le code \texttt{jps}}
36
37 \subsubsection{Le choix de l'objet}
38
39 \begin{itemize}
40   \item \textsf{[section] n newanneau} : choix de l'anneau cylindrique défini par sa section, coordonnées des sommets dans le plan $Oyz$.
41   \item \textsf{2\textvisiblespace 1.5\textvisiblespace 6\textvisiblespace [4\textvisiblespace 16]\textvisiblespace newcylindre} : choix du cylindre vertical avec comme caractéristiques :
42   \begin{itemize}
43     \item \texttt{rayon=1.5} ;
44     \item \texttt{z0=2} est la position du centre de la base inférieure sur l'axe $\mathsf{Oz}$ ;
45     \item \texttt{z1=6} est la position du centre de la base supérieure sur l'axe $\mathsf{Oz}$ ;
46     \item \texttt{[4 16]} : le cylindre est découpé verticalement en 4 morceaux et horizontalement en 16 secteurs.
47   \end{itemize}
48   \end{itemize}
49
50 \subsubsection{Les transformations}
51
52 \begin{itemize}
53   \item \texttt{\{-1\textvisiblespace 2\textvisiblespace 5\textvisiblespace translatepoint3d\} solidtransform} : l'objet préalablement sélectionné subit une translation au point de coordonnées $\mathsf{(x=-1,y=2,z=5)}$.
54   \item \texttt{\{90\textvisiblespace 0\textvisiblespace 45\textvisiblespace rotateOpoint3d\} solidtransform} : l'objet préalablement sélectionné subit une rotation autour des axes $\mathsf{(Ox,Oy,Oz)}$, dans cet ordre,
55   de 90$^\mathsf{o}$ autour de $\mathsf{(Ox)}$ suivie d'une rotation de 45$^\mathsf{o}$ autour de $\mathsf{(Oz)}$.
56 \end{itemize}
57
58 \subsubsection{Le choix de la couleur de l'objet}
59
60 \begin{itemize}
61   \item dup (jaune) outputcolors : l'objet de couleur jaune éclairé en lumière blanche.
62 \end{itemize}
63 \subsubsection{La fusion des objets}
64 \begin{itemize}
65   \item Elle se fait avec l'instruction \texttt{solidfuz}.
66 \end{itemize}
67
68 \subsubsection{Le dessin des objets}
69 \begin{itemize}
70   \item Le tracé a trois options :
71   \begin{itemize}
72     \item \texttt{drawsolid} : tracé des arêtes uniquement, les arêtes cachées sont en pointillés ;
73     \item \texttt{drawsolid*} : tracé et remplissage des solides dans l'ordre de leur programmation (option peu intéressante à priori), avec le dessin des arêtes cachées
74     en pointillés~;
75     \item \texttt{drawsolid**} : tracé et remplissage des solides avec l'algorithme du peintre : seules les parties vues par l'observateur
76     sont dessinées.
77   \end{itemize}
78 \end{itemize}
79 \begin{center}
80 \psset{lightsrc=50 -50 50,viewpoint=40 16 32 rtp2xyz,Decran=40}
81 \psset{unit=0.4}
82 \begin{minipage}{0.3\linewidth}
83 \begin{pspicture}(-6,-5)(6,7)
84 \psframe*[linecolor=gray!40](-6,-5)(6,7)
85 \codejps{
86 % solide 1
87  /tour {
88     -6 1.5 6 [4 16] newcylindre
89     dup (jaune) outputcolors
90     } def
91 % solide 2
92  /anneau {
93     [4 -1 4 1 3 1 3 -1] 24 newanneau
94    {0 0 -1 translatepoint3d} solidtransform
95     dup (orange) outputcolors
96     } def
97 % fusion
98     tour anneau solidfuz
99     drawsolid}
100 \end{pspicture}
101 \end{minipage}
102 \hfill
103 \begin{minipage}{0.3\linewidth}
104 \begin{pspicture}(-6,-5)(6,7)
105 \psframe*[linecolor=gray!40](-6,-5)(6,7)
106 \codejps{
107 % solide 1
108  /tour {
109     -6 1.5 6 [4 16] newcylindre
110     dup (jaune) outputcolors
111     } def
112 % solide 2
113  /anneau {
114     [4 -1 4 1 3 1 3 -1] 24 newanneau
115    {0 0 -1 translatepoint3d} solidtransform
116     dup (orange) outputcolors
117     } def
118 % fusion
119     tour anneau solidfuz
120     drawsolid*}
121 \end{pspicture}
122 \end{minipage}
123 \hfill
124 \begin{minipage}{0.3\linewidth}
125 \begin{pspicture}(-6,-5)(6,7)
126 \psframe*[linecolor=gray!40](-6,-5)(6,7)
127 \codejps{
128 % solide 1
129  /tour {
130     -6 1.5 6 [4 16] newcylindre
131     dup (jaune) outputcolors
132     } def
133 % solide 2
134  /anneau {
135     [4 -1 4 1 3 1 3 -1] 24 newanneau
136    {0 0 -1 translatepoint3d} solidtransform
137     dup (orange) outputcolors
138     } def
139 % fusion
140     tour anneau solidfuz
141     drawsolid**}
142 \psPoint(0,0,8){Z}
143 \psPoint(0,0,6){Z'}
144 \psline[arrowsize=0.3,arrowinset=0.2]{->}(Z')(Z)
145 \uput[u](Z){$z$}
146 \end{pspicture}
147 \end{minipage}
148 \end{center}
149 \lstset{language=PostScript}
150 \begin{lstlisting}
151 \psset{lightsrc=50 -50 50,viewpoint=50 20 50 rtp2xyz,Decran=50}
152 \begin{pspicture}(-6,-2)(6,8)
153 \psframe(-6,-2)(6,8)
154 \codejps{
155 % solide 1
156  /tour {
157     -6 1.5 6 [4 16] newcylindre
158     dup (jaune) outputcolors
159     } def
160 % solide 2
161  /anneau {
162     [4 -1 4 1 3 1 3 -1] 24 newanneau
163    {0 0 -1 translatepoint3d} solidtransform
164     dup (orange) outputcolors
165     } def
166 % fusion
167     tour anneau solidfuz
168     drawsolid**}
169 \end{pspicture}
170 \end{lstlisting}
171
172 \newpage
173
174 \subsection{Un ion chlorure}
175
176 \begin{minipage}{6cm}
177 \setlength{\columnseprule}{1pt}
178 \begin{pspicture}(-3,-4)(3,4)
179 \psset{lightsrc=100 -50 -10,lightintensity=3,viewpoint=200 20 10 rtp2xyz,Decran=20}
180 \psframe(-2.5,-2.5)(2.5,2.5)
181 {\psset{linewidth=0.5\pslinewidth}
182 \codejps{
183 /Cl {9.02  [18 16] newsphere
184  {-90 0 0 rotateOpoint3d} solidtransform
185  dup (Green) outputcolors} def
186 /Cl1 { Cl {10.25 10.25 10.25 translatepoint3d} solidtransform } def
187 /Cl2 { Cl {10.25 -10.25 10.25 translatepoint3d} solidtransform } def
188 /Cl3 { Cl {-10.25 -10.25 10.25 translatepoint3d} solidtransform } def
189 /Cl4 { Cl {-10.25 10.25 10.25 translatepoint3d} solidtransform } def
190 /Cl5 { Cl {10.25 10.25 -10.25 translatepoint3d} solidtransform } def
191 /Cl6 { Cl {10.25 -10.25 -10.25 translatepoint3d} solidtransform } def
192 /Cl7 { Cl {-10.25 -10.25 -10.25 translatepoint3d} solidtransform } def
193 /Cl8 { Cl {-10.25 10.25 -10.25 translatepoint3d} solidtransform } def
194 /Cs {8.38  [18 16] newsphere
195  dup (White) outputcolors} def
196 %
197 /Cl12{ Cl1 Cl2 solidfuz} def
198 /Cl123{ Cl12 Cl3 solidfuz} def
199 /Cl1234{ Cl123 Cl4 solidfuz} def
200 /Cl12345{ Cl1234 Cl5 solidfuz} def
201 /Cl123456{ Cl12345 Cl6 solidfuz} def
202 /Cl1234567{ Cl123456 Cl7 solidfuz} def
203 /Cl12345678{ Cl1234567 Cl8 solidfuz} def
204 /C_Cs { Cl12345678 Cs solidfuz} def
205 C_Cs  drawsolid**}}%
206 %\psSolid[object=cube,a=20.5,action=draw,linestyle=dashed]%
207 \psPoint(0,0,0){P}
208 \psPoint(10.25,10.25,10.25){Cl1}
209 \psPoint(10.25,-10.25,10.25){Cl2}
210 \psPoint(-10.25,-10.25,10.25){Cl3}
211 \psPoint(-10.25,10.25,10.25){Cl4}
212 \psPoint(10.25,10.25,-10.25){Cl5}
213 \psPoint(10.25,-10.25,-10.25){Cl6}
214 \psPoint(-10.25,-10.25,-10.25){Cl7}
215 \psPoint(-10.25,10.25,-10.25){Cl8}
216 \pspolygon[linestyle=dashed](Cl1)(Cl2)(Cl3)(Cl4)
217 \pspolygon[linestyle=dashed](Cl5)(Cl6)(Cl7)(Cl8)
218 \psline[linestyle=dashed](Cl2)(Cl6)
219 \psline[linestyle=dashed](Cl3)(Cl7)
220 \psline[linestyle=dashed](Cl1)(Cl5)
221 \psline[linestyle=dashed](Cl4)(Cl8)
222 \pcline[offset=0.5]{<->}(Cl2)(Cl1)
223 \aput{:U}{a}
224 \pcline[offset=0.5]{<->}(Cl6)(Cl2)
225 \aput{:U}{a}
226 \end{pspicture}
227 \end{minipage}
228 \hfill
229 \begin{minipage}{14cm}
230 \footnotesize
231 \begin{verbatim}
232 \codejps{
233 /Cl {9.02  [12 8] newsphere
234  {-90 0 0 rotateOpoint3d} solidtransform
235  dup (Green) outputcolors} def
236 /Cl1 { Cl {10.25 10.25 10.25 translatepoint3d} solidtransform } def
237 /Cl2 { Cl {10.25 -10.25 10.25 translatepoint3d} solidtransform } def
238 /Cl3 { Cl {-10.25 -10.25 10.25 translatepoint3d} solidtransform } def
239 /Cl4 { Cl {-10.25 10.25 10.25 translatepoint3d} solidtransform } def
240 /Cl5 { Cl {10.25 10.25 -10.25 translatepoint3d} solidtransform } def
241 /Cl6 { Cl {10.25 -10.25 -10.25 translatepoint3d} solidtransform } def
242 /Cl7 { Cl {-10.25 -10.25 -10.25 translatepoint3d} solidtransform } def
243 /Cl8 { Cl {-10.25 10.25 -10.25 translatepoint3d} solidtransform } def
244 /Cs {8.38  [12 8] newsphere
245  dup (White) outputcolors} def
246 /Cl12{ Cl1 Cl2 solidfuz} def
247 /Cl123{ Cl12 Cl3 solidfuz} def
248 /Cl1234{ Cl123 Cl4 solidfuz} def
249 /Cl12345{ Cl1234 Cl5 solidfuz} def
250 /Cl123456{ Cl12345 Cl6 solidfuz} def
251 /Cl1234567{ Cl123456 Cl7 solidfuz} def
252 /Cl12345678{ Cl1234567 Cl8 solidfuz} def
253 /C_Cs { Cl12345678 Cs solidfuz} def
254 C_Cs  drawsolid**}
255 \end{verbatim}
256 \end{minipage}
257
258 On définit l'ion chlorure $\mathrm{Cl^-}$ :
259 \begin{verbatim}
260 /Cl {9.02  [12 8] newsphere
261  {-90 0 0 rotateOpoint3d} solidtransform
262  dup (Green) outputcolors} def
263 \end{verbatim}
264 que l'on recopie aux sommets du cube :
265 \begin{verbatim}
266 /Cl1 { Cl {10.25 10.25 10.25 translatepoint3d} solidtransform } def
267 /Cl2 { Cl {10.25 -10.25 10.25 translatepoint3d} solidtransform } def
268 /Cl3 { Cl {-10.25 -10.25 10.25 translatepoint3d} solidtransform } def
269 /Cl4 { Cl {-10.25 10.25 10.25 translatepoint3d} solidtransform } def
270 /Cl5 { Cl {10.25 10.25 -10.25 translatepoint3d} solidtransform } def
271 /Cl6 { Cl {10.25 -10.25 -10.25 translatepoint3d} solidtransform } def
272 /Cl7 { Cl {-10.25 -10.25 -10.25 translatepoint3d} solidtransform } def
273 /Cl8 { Cl {-10.25 10.25 -10.25 translatepoint3d} solidtransform } def
274 \end{verbatim}
275 Puis l'ion césium $\mathrm{Cs^+}$, placé au centre :
276 \begin{verbatim}
277 /Cs {8.38  [12 8] newsphere
278  dup (White) outputcolors} def
279 \end{verbatim}
280 Ensuite on fusionne deux par deux les différentes sphères.
281
282 \vfill
283
284
285 \subsection{Un prototype de véhicule}
286 \begin{center}
287 \psset{lightsrc=100 0 100,viewpoint=25 10 10,Decran=30}
288 \begin{pspicture}(-6,-4)(6,8)
289 \pstVerb{/Pneu {
290    /m {90 4 div} bind def
291    /Scos {m cos 2 m mul cos add 3 m mul cos add} bind def
292    /Z0 {h 4 div} bind def
293    /c {Z0 Scos div} bind def
294    /Z1 {Z0 c m cos mul add} bind def
295    /Z2 {Z1 c m 2 mul cos mul add} bind def
296    /R1 {R c m sin mul sub} bind def
297    /R2 {R1 c m 2 mul sin mul sub} bind def
298    /R3 {R2 c m 3 mul sin mul sub} bind def
299    R h 4 div neg % 1
300    R h 4 div % 2
301    R1 Z1 % 3
302    R2 Z2 % 4
303    R3 h 2 div % 5
304    r h 2 div  % 6
305    r h 2 div neg  % 7
306    R3 h 2 div neg % 8
307    R2 Z2 neg % 9
308    R1 Z1 neg % 10
309    } def}%
310 \grille
311 \codejps{
312 /roue12 {
313 % solide 1
314     /R 2 def /r 1 def /h 1 def
315     [Pneu] 36 newanneau
316      {90 0 90 rotateOpoint3d} solidtransform
317      {3 4 2 translatepoint3d} solidtransform
318      dup (White) outputcolors
319 % solide 2
320     [Pneu] 36 newanneau
321     {90 0 90 rotateOpoint3d} solidtransform
322    {-3 4 2 translatepoint3d} solidtransform
323     dup (White) outputcolors
324 % fusion
325     solidfuz } def
326 /axe12{
327 0 0.1 6 [4 16] newcylindre
328 {90 0 90 rotateOpoint3d} solidtransform
329 {-3 4 2  translatepoint3d} solidtransform
330 dup (White) outputcolors
331 } def
332 /roue12axes {
333 roue12 axe12 solidfuz } def
334 /roue34 {
335 % solide 3
336    /R 1.5 def /r 1 def /h 1 def
337     [Pneu] 36 newanneau
338     {90 0 110 rotateOpoint3d} solidtransform
339    {3 -4 1.5 translatepoint3d} solidtransform
340     dup (White) outputcolors
341 % solide 4
342     [Pneu] 36 newanneau
343    {90 0 110 rotateOpoint3d} solidtransform
344    {-3 -4 1.5 translatepoint3d} solidtransform
345     dup (White) outputcolors
346 % fusion
347     solidfuz } def
348 /axe34{
349 0 0.1 6  [16 16] newcylindre
350 {90 0 90 rotateOpoint3d} solidtransform
351 {-3 -4 1.5  translatepoint3d} solidtransform
352 dup (White) outputcolors
353 } def
354 /roue34axes34 {
355 roue34 axe34 solidfuz } def
356 /roues {roue34axes34 roue12axes solidfuz} def
357 /chassis {
358 0 1 8  [4 16] newcylindre
359 {100 0 0 rotateOpoint3d} solidtransform
360 {0 4 2.5  translatepoint3d} solidtransform
361 dup (White) outputcolors
362 } def
363 roues chassis solidfuz
364     drawsolid**}
365 \psPoint(0,0,2.7){Z'}
366 \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(Z')(Z)
367 \end{pspicture}
368 \end{center}
369 Il faut opérer en plusieurs étapes en fusionnant les solides deux par deux.
370 \begin{itemize}
371   \item On fusionne d'abord les deux roues avant \texttt{roue12}:
372   \begin{verbatim}
373 /roue12 {
374 % solide 1
375     /R 2 def /r 1 def /h 1 def
376     [Pneu] 36 newanneau
377      {90 0 90 rotateOpoint3d} solidtransform
378      {3 4 2 translatepoint3d} solidtransform
379      dup (White) outputcolors
380 % solide 2
381     [Pneu] 36 newanneau
382     {90 0 90 rotateOpoint3d} solidtransform
383    {-3 4 2 translatepoint3d} solidtransform
384     dup (White) outputcolors
385 % fusion
386     solidfuz } def
387   \end{verbatim}
388   \item Puis ces deux roues et leur axe :
389   \begin{verbatim}
390 /axe12{
391 0 0.1 6  [4 16] newcylindre
392 {90 0 90 rotateOpoint3d} solidtransform
393 {-3 4 2  translatepoint3d} solidtransform
394 dup (White) outputcolors
395 } def
396 /roue12axes {
397 roue12 axe12 solidfuz } def
398 \end{verbatim}
399   \item On opère de même pour les roues arrière et leur axe :
400   \begin{verbatim}
401 /roue34 {
402 % solide 3
403    /R 1.5 def /r 1 def /h 1 def
404     [Pneu] 36 newanneau
405     {90 0 110 rotateOpoint3d} solidtransform
406    {3 -4 1.5 translatepoint3d} solidtransform
407     dup (White) outputcolors
408 % solide 4
409     [Pneu] 36 newanneau
410    {90 0 110 rotateOpoint3d} solidtransform
411    {-3 -4 1.5 translatepoint3d} solidtransform
412     dup (White) outputcolors
413 % fusion
414     solidfuz } def
415 /axe34{
416 0 0.1 6 [16 16] newcylindre
417 {90 0 90 rotateOpoint3d} solidtransform
418 {-3 -4 1.5  translatepoint3d} solidtransform
419 dup (White) outputcolors
420 } def
421 /roue34axes34 {
422 roue34 axe34 solidfuz } def
423 /roues {roue34axes34 roue12axes solidfuz} def
424 \end{verbatim}
425
426 \item La dernière étape consiste à fusionner les deux solides ainsi
427   obtenus avec le semblant de chassis~:
428 \begin{verbatim}
429 /chassis {
430 0 1 8  [4 16] newcylindre
431 {100 0 0 rotateOpoint3d} solidtransform
432 {0 4 2.5  translatepoint3d} solidtransform
433 dup (White) outputcolors
434 } def
435 roues chassis solidfuz
436     drawsolid**}
437 \end{verbatim}
438 \end{itemize}
439
440
441 \subsection{Une roue ou bien une station spatiale !}
442
443 \begin{center}
444 \begin{pspicture}(-6,-5)(6,6)
445 \psset{lightsrc=50 -50 50,viewpoint=40 50 60,Decran=60,linewidth=0.5\pslinewidth}
446 %\psframe*[linecolor=black](-6,-5)(6,5)
447 \codejps{
448  /rayon0 {
449      1 0.2 6 [4 16] newcylindre
450      {90 0 0 rotateOpoint3d} solidtransform
451       dup (White) outputcolors
452    } def
453 36 36 360 {
454     /angle exch def
455   /rayon1 {
456      1 0.2 6  [4 16] newcylindre
457      {90 0 angle rotateOpoint3d} solidtransform
458       dup (White) outputcolors
459    } def
460   /rayons {rayon0 rayon1 solidfuz} def
461   /rayon0 rayons def
462   } for
463  /moyeu { -2 1 2  [4 10] newcylindre dup (jaune) outputcolors} def
464  /rayonsmoyeu {rayons  moyeu solidfuz} def
465  /pneu {2 7 [18 36] newtore dup (White) outputcolors} def
466  /ROUE {pneu rayonsmoyeu solidfuz} def
467   ROUE  drawsolid**}
468 \end{pspicture}
469 \end{center}
470 On définit d'abord le premier rayon :
471 \begin{verbatim}
472  /rayon0 {
473      1 0.2 6 [4 16] newcylindre
474      {90 0 0 rotateOpoint3d} solidtransform
475       dup (White) outputcolors
476    } def
477 \end{verbatim}
478 Puis dans une boucle on fusionne tous les rayons de la roue :
479 \begin{verbatim}
480 36 36 360 {
481     /angle exch def
482   /rayon1 {
483      1 0.2 6  [4 16] newcylindre
484      {90 0 angle rotateOpoint3d} solidtransform
485       dup (White) outputcolors
486    } def
487   /rayons {rayon0 rayon1 solidfuz} def
488   /rayon0 rayons def
489   } for
490 \end{verbatim}
491 Ensuite, on dessine le moyeu et la circonférence (pneu) de la roue pour
492 enfin fusionner l'ensemble : 
493 \begin{verbatim}
494  /moyeu { -0.5 1 0.5  [4 10] newcylindre dup (White) outputcolors} def
495  /rayonsmoyeu {rayons  moyeu solidfuz} def
496  /pneu {2 7 [18 36] newtore dup (jaune) outputcolors} def
497  /ROUE {pneu rayonsmoyeu solidfuz} def
498   ROUE  drawsolid**
499 \end{verbatim}
500
501
502 \subsection{Intersection de deux cylindres}
503
504 \begin{center}
505 \begin{pspicture}(-6,-3)(6,3)
506 \psset{lightsrc=50 -50 50,viewpoint=100 -30
507 40,Decran=100,linewidth=0.5\pslinewidth, unit=0.75}
508 %\psframe*[linecolor=black](-6,-5)(6,5)
509 \codejps{
510  /cylindre1 {
511      -6 2 6 [36 36] newcylindrecreux %newcylindre
512      {90 0 0 rotateOpoint3d} solidtransform
513       dup (White) (White) inoutputcolors
514    } def
515  /cylindre2 {
516      -6 2 6 [36 36] newcylindrecreux% newcylindre
517      {90 0 90 rotateOpoint3d} solidtransform
518       dup (White) (White) inoutputcolors
519    } def
520  /UnionCylindres {cylindre1 cylindre2 solidfuz} def
521   UnionCylindres  drawsolid**}
522 \end{pspicture}
523 \end{center}
524 \begin{verbatim}
525 \codejps{
526  /cylindre1 {
527      -6 2 6 [36 36] newcylindrecreux %newcylindre
528      {90 0 0 rotateOpoint3d} solidtransform
529       dup (White) (White) inoutputcolors
530    } def
531  /cylindre2 {
532      -6 2 6 [36 36] newcylindrecreux% newcylindre
533      {90 0 90 rotateOpoint3d} solidtransform
534       dup (White) (White) inoutputcolors
535    } def
536  /UnionCylindres {cylindre1 cylindre2 solidfuz} def
537   UnionCylindres  drawsolid**}
538 \end{verbatim}
539
540
541
542 \subsection{Intersection d'une sphère et d'un cylindre}
543
544 Dans cette partie on dessine en utilisant
545 \verb+\psSolid[object=courbe]+ le contour de l'intersection.
546
547 \begin{minipage}{0.4\linewidth}
548 \psset{unit=0.5,lightsrc=50 -50 50,viewpoint=100 0 0 rtp2xyz,Decran=110,linewidth=0.5\pslinewidth} 
549 \begin{pspicture}(-5,-6)(5,6)
550 \defFunction{F}(t){t cos dup mul 5 mul}{t cos t sin mul 5 mul}{t sin 5 mul}
551 \codejps{%
552    /cylindre1 {
553        -5 2.5 5 [36 36] newcylindre
554        {2.5 0 0 translatepoint3d} solidtransform
555         dup (White) outputcolors
556    } def
557    /sphere1 {
558         5 [36 72] newsphere
559         dup (White) outputcolors
560    } def
561    /CS {cylindre1 sphere1 solidfuz} def
562    CS drawsolid**}
563 \psSolid[object=courbe,r=0,
564    function=F,
565    range=0 360,
566    linecolor=red,linewidth=4\pslinewidth]
567 \psPoint(0,0,0){O}
568 %% \makeatletter
569 %% \parametricplot[linecolor=red,linewidth=2\pslinewidth]{0}{360}{%
570 %%    \tx@optionssolides
571 %%     SolidesDict begin
572 %%     t cos dup mul 5 mul % x
573 %%     t cos t sin mul 5 mul % y
574 %%     t sin 5 mul % z
575 %%    3dto2d cm_1 exch cm_1 exch
576 %%    end}
577 %% \makeatother
578 \end{pspicture}
579 \end{minipage}
580 \begin{minipage}{0.55\linewidth}
581 \begin{verbatim}
582 \codejps{%
583    /cylindre1 {
584        -5 2.5 5 [36 36] newcylindre
585        {2.5 0 0 translatepoint3d} solidtransform
586         dup (White) outputcolors
587    } def
588    /sphere1 {
589         5 [36 72] newsphere
590         dup (White) outputcolors
591    } def
592    /CS {cylindre1 sphere1 solidfuz} def
593    CS drawsolid**}
594 \psPoint(0,0,0){O}
595 \psSolid[object=courbe,r=0,
596    function=F,
597    range=0 360,
598    linecolor=red,linewidth=4\pslinewidth]
599 \end{verbatim}
600 \end{minipage}
601
602
603 \subsection{Réunion de deux anneaux}
604
605 \begin{minipage}{0.5\linewidth}
606 \begin{pspicture}(-5,-4)(3,3)
607 \psset{lightsrc=50 50 50,viewpoint=40 50 60,Decran=30,unit=0.85}
608 \psframe(-5,-4)(3,3)
609 \codejps{
610  /anneau1 {1 7 [12 36] newtore
611  {0 0 0 translatepoint3d} solidtransform
612  dup (White) outputcolors} def
613  /anneau2 {1 7 [12 36] newtore
614  {90 0 0 rotateOpoint3d} solidtransform
615  {7 0 0 translatepoint3d} solidtransform
616  dup (White) outputcolors} def
617  /collier {anneau1 anneau2 solidfuz} def
618   collier  drawsolid**}
619 \end{pspicture}
620 \end{minipage}
621 %
622 \begin{minipage}{0.59\linewidth}
623 \begin{verbatim}
624 \codejps{
625  /anneau1 {1 7 [9 18] newtore
626  {0 0 0 translatepoint3d} solidtransform
627  dup (White) outputcolors} def
628  /anneau2 {1 7 [9 18] newtore
629  {90 0 0 rotateOpoint3d} solidtransform
630  {7 0 0 translatepoint3d} solidtransform
631  dup (White) outputcolors} def
632  /collier {anneau1 anneau2 solidfuz} def
633   collier  drawsolid**}
634 \end{verbatim}
635 \end{minipage}
636
637
638
639 \subsection{La molécule de méthane : modèle en bois}
640
641 \begin{minipage}{0.42\linewidth}
642 \begin{pspicture}(-3.5,-4)(3.2,5)
643 \psset{lightsrc=50 50 10,lightintensity=2,viewpoint=100 50 20 rtp2xyz,
644   Decran=30}
645 \psset{linecolor={[cmyk]{0,0.72,1,0.45}},linewidth=0.5\pslinewidth,
646   unit=1}
647 \psframe[fillstyle=solid,fillcolor=green!20](-4,-4)(3.2,5)
648 \pstVerb{/hetre {0.764 0.6 0.204 setrgbcolor} def
649          /chene {0.568 0.427 0.086 setrgbcolor} def
650          /bois {0.956 0.921 0.65 setrgbcolor} def
651          }%
652 \codejps{
653  /H1 {
654  2  [18 16] newsphere
655  {-90 0 0 rotateOpoint3d} solidtransform
656  {0 10.93 0 translatepoint3d} solidtransform
657  dup (hetre) outputcolors} def
658   /L1 {
659      0 0.25 10  [12 10] newcylindre
660      {-90 0 0 rotateOpoint3d} solidtransform
661       dup (bois) outputcolors
662    } def
663 /HL1{ H1 L1  solidfuz} def
664 /HL2 { HL1 {0 0 -109.5 rotateOpoint3d} solidtransform } def
665 /HL3 { HL2 {0 -120 0 rotateOpoint3d} solidtransform } def
666 /HL4 { HL2 {0 120 0 rotateOpoint3d} solidtransform } def
667  /C {3  [18 16] newsphere
668   {90 0 0 rotateOpoint3d} solidtransform
669    dup (chene) outputcolors} def
670 /HL12 { HL1 HL2 solidfuz} def
671 /HL123 { HL12 HL3 solidfuz} def
672 /HL1234 { HL123 HL4 solidfuz} def
673 /methane { HL1234 C solidfuz} def
674   methane  drawsolid**}
675 \end{pspicture}
676 \end{minipage}
677 %
678 \begin{minipage}{0.69\linewidth}
679 \begin{verbatim}
680 \pstVerb{/hetre {0.764 0.6 0.204 setrgbcolor} def
681          /chene {0.568 0.427 0.086 setrgbcolor} def
682          /bois {0.956 0.921 0.65 setrgbcolor} def
683          }%
684 \codejps{
685  /H1 {
686  2  [18 16] newsphere
687  {-90 0 0 rotateOpoint3d} solidtransform
688  {0 10.93 0 translatepoint3d} solidtransform
689  dup (hetre) outputcolors} def
690   /L1 {
691      0 0.25 10  [12 10] newcylindre
692      {-90 0 0 rotateOpoint3d} solidtransform
693       dup (bois) outputcolors
694    } def
695  /HL1{ H1 L1  solidfuz} def
696  /HL2 { 
697    HL1 {0 0 -109.5 rotateOpoint3d} solidtransform 
698    } def
699  /HL3 { 
700    HL2 {0 -120 0 rotateOpoint3d} solidtransform } def
701  /HL4 { 
702    HL2 {0 120 0 rotateOpoint3d} solidtransform } def
703  /C {3  [18 16] newsphere
704    {90 0 0 rotateOpoint3d} solidtransform
705     dup (chene) outputcolors} def
706  /HL12 { HL1 HL2 solidfuz} def
707  /HL123 { HL12 HL3 solidfuz} def
708  /HL1234 { HL123 HL4 solidfuz} def
709  /methane { HL1234 C solidfuz} def 
710  methane drawsolid**}
711 \end{verbatim}
712 \end{minipage}
713
714
715 \subsection{L'ion thiosulfate}
716 \input \datapath S2O3
717 On définit d'abord les deux atomes de soufre placés sur l'axe $Oz$.
718 $\mathrm{S_1}$ est placé en $O$.  
719 \begin{verbatim}
720 \codejps{
721 /Soufre1 {3.56  [20 16] newsphere
722  dup (Yellow) outputcolors} def
723 /Soufre2 {3.56  [20 16] newsphere
724  {0 0.000 20.10 translatepoint3d} solidtransform
725  dup (Yellow) outputcolors} def
726 \end{verbatim}
727 Puis la liaison simple \textsf{S-O} avec la convention suivante : c'est un
728 cylindre avec une moitié rouge -celle qui est liée à \textsf{O}, et l'autre
729 jaune -celle du côté de \textsf{S}.
730 \begin{verbatim}
731 /LiaisonR {
732      7.5 0.5 15  [10 10] newcylindre
733       dup (Red) outputcolors
734    } def
735 /LiaisonY {
736      0 0.5 7.5  [10 10] newcylindre
737       dup (Yellow) outputcolors
738    } def
739 /Liaison{LiaisonR LiaisonY solidfuz} def
740 \end{verbatim}
741 L'atome d'oxygène, sa liaison, puis la mise en position de l'ensemble :
742 \begin{verbatim}
743 /Ox {2.17  [20 16] newsphere
744      {0 0 15 translatepoint3d} solidtransform
745      dup (Red) outputcolors} def
746 /LO { Liaison Ox solidfuz} def
747 /LO1 { LO  {0 -109.5 0 rotateOpoint3d} solidtransform } def
748 /LOx1 { LO1  {0 0 120 rotateOpoint3d} solidtransform } def
749 % fin liaison simple S-O
750 \end{verbatim}
751 La liaison double double \textsf{S=O}, on se sert de la liaison simple
752 définie précédemment et on la duplique en la décalant suivant l'axe $Ox$ de
753 0,75~cm.
754 \begin{verbatim}
755 % Liaison double S=O
756 /LiaisonD1 {Liaison {-0.75 0 0 translatepoint3d} solidtransform} def
757 /LiaisonD2 {Liaison {0.75 0 0 translatepoint3d} solidtransform} def
758 /LiaisonDD { LiaisonD1 LiaisonD2 solidfuz} def
759 \end{verbatim}
760 On lie cette liaison double avec l'atome d'\textsf{O} :
761 \begin{verbatim}
762 /LiaisonDOx {LiaisonDD Ox solidfuz} def
763 \end{verbatim}
764 et par deux rotations successives on positionne les deux liaisons
765 \textsf{=O} : 
766 \begin{verbatim}
767 /LiaisonDOx1 {LiaisonDOx {0 -109.5 0 rotateOpoint3d} solidtransform } def
768 /LiaisonDOx2 {LiaisonDOx1 {0  0 -120 rotateOpoint3d} solidtransform } def
769 \end{verbatim}
770 L'étape suivante consiste à fusionner ces deux liaisons :
771 \begin{verbatim}
772 /LO12 { LiaisonDOx1 LiaisonDOx2 solidfuz} def
773 /LO123 {LO12 LOx1 solidfuz} def
774 \end{verbatim}
775 On passe ensuite à la liaison simple \textsf{S-S} :
776 \begin{verbatim}
777 % liaison simple S-S
778 /L4 { 0 0.5 20.10  [16 10] newcylindre
779       dup (Yellow) outputcolors
780     } def
781 \end{verbatim}
782 Que l'on fusionne avec les deux atomes \textsf{S-S} :
783 \begin{verbatim}
784 /S1L4{ Soufre1 L4 solidfuz} def
785 /S1S2L4{ S1L4 Soufre2 solidfuz} def
786 \end{verbatim}
787 La dernière étape consiste à fusionner \textsf{S-S} et les trois \textsf{O} déjà munis de leur liaisons :
788 \begin{verbatim}
789 /S2O3 { S1S2L4 LO123 solidfuz} def
790 S2O3  drawsolid**}
791 \end{verbatim}

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.