summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pst-rubans/pst-rubans.tex
blob: 69861418c9892807641dd028139cc39d02200b6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
%% Package `pst-rubans.tex'
%%
%% This program can be redistributed and/or modified under
%% the terms of the LaTeX Project Public License Distributed
%% from CTAN archives in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-rubans' is a PSTricks package for 
%%   drawing 3 dimensional bands.
%%
%%
%% Authors  :   Manuel Luque <Manuel.Luque27@gmail.com>
%%              Herbert Voss <hvoss@tug.org>
%%
\csname PSTRubansLoaded\endcsname
\let\PSTRubansLoaded\endinput
%
% Require PSTricks and pst-solides3d
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTGradLoaded\endinput \else\input pst-solides3d.tex\fi
\ifx\PSTXKeyLoaded\endinput \else\input pst-xkey.tex\fi
%
\def\fileversion{1.2}
\def\filedate{2011/02/10}
%
\message{`PST-Rubans' v\fileversion, \filedate\space (ML/CJ/DG/HV)}
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
%
\pst@addfams{pst-rubans}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Definition des differentes variables pour PSTricks
%% ruban en helice circulaire
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\define@key[psset]{pst-rubans}{dZ}{\def\pst@rubans@dZ{#1}} % hauteur du ruban
\psset[pst-rubans]{dZ=0.5} % hauteur du ruban
\define@key[psset]{pst-rubans}{spires}{\def\pst@rubans@spires{#1}} %
\psset[pst-rubans]{spires=10} % nombre de spires d'un ruban
\define@key[psset]{pst-rubans}{rubans}{\def\pst@rubans@rubans{#1}} %
\psset[pst-rubans]{rubans=1} % nombre de spires d'un ruban

\def\pshelices{\pst@object{pshelices}}
%% usage : \pshelices[options](x,y,z)
\def\pshelices@i{\@ifnextchar({\pshelices@ii}{\pshelices@ii(0,0,0)}}
\def\pshelices@ii(#1,#2,#3){%
  \pst@killglue%
  \begingroup%
  \use@par%
\pstVerb{
/dz \pst@rubans@dZ\space def
/initvar_SpiralHelice {
  /rubans \pst@rubans@rubans\space def
  /phase {360 rubans div} bind def
  /Rayon \pst@solides@R\space def
  /Hauteur \pst@solides@h\space def
  /PHI 0 def
  /x@0 Rayon PHI cos mul def
  /y@0 Rayon PHI sin mul def
  /z@0 0 def
  /pulsation {6.28319 Hauteur div \pst@rubans@spires\space mul} bind def
  /x@1 {Rayon t@ pulsation mul 57.295 mul PHI add cos mul} def
  /y@1 {Rayon t@ pulsation mul 57.295 mul PHI add sin mul} def
  /z@1 {t@} def
  /dA {Hauteur \pst@solides@resolution\space div} bind def
  /tableau_des_sommets [
   rubans {
      dA dA Hauteur{/t@ exch def
                 x@0 y@0 z@0
                 x@1 y@1 z@1
                 x@1 y@1 z@1 dz add
                 x@0 y@0 z@0 dz add
                 /x@0 x@1 def
                 /y@0 y@1 def
                 /z@0 z@1 def
      } for
    /PHI PHI phase add def
    /x@0 Rayon PHI cos mul def
    /y@0 Rayon PHI sin mul def
    /z@0 0 def
   } repeat ] def
  /Sommets {tableau_des_sommets aload pop} def
  /NbrePoints tableau_des_sommets length 3 div cvi def
  /Faces  {0 4 NbrePoints 4 sub {
            /Ni exch def
            [ Ni Ni 1 add  Ni 2 add Ni 3 add]
          } for
  } def
  /Faces_internes {0 4 NbrePoints 4 sub {
      /Ni exch def
      [Ni 3 add Ni 2 add Ni 1 add Ni]
    } for
  } def
} def
initvar_SpiralHelice
}%
%\psSolid[object=new,sommets=Sommets,fillcolor=\psincolor,faces={Faces_internes}](#1,#2,#3)%
  \psSolid[object=new,sommets=Sommets,faces={Faces},hollow](#1,#2,#3)%
  \endgroup%
  \ignorespaces%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ruban en helice torique
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\define@key[psset]{pst-rubans}{dPHI}{\def\pst@rubans@dPHI{#1}} % hauteur du ruban
\psset[pst-rubans]{dPHI=5} % hauteur du ruban en degrés

\def\psSpiralRing{\pst@object{psSpiralRing}}
%% usage : \psSpiralRing[options]
\def\psSpiralRing@i{\@ifnextchar({\psSpiralRing@ii}{\psSpiralRing@ii(0,0,0)}}
\def\psSpiralRing@ii(#1,#2,#3){%
%  \pst@killglue%
  \begingroup%
  \use@par%
  \pstVerb{%
 /ri \pst@solides@rO\space def % rayon intérieur
 /rm \pst@solides@rI\space def % rayon moyen
 /spires \pst@rubans@spires\space def
 /dPHI \pst@rubans@dPHI\space def
 /initvar_SpiralRing {
   /THETA {PHI spires 2 mul mul} def
   /x@ {rm ri THETA cos mul add PHI cos mul} def
         /y@ {rm ri THETA cos mul add PHI sin mul} def
         /z@ {ri THETA sin mul} def
         /dt@ {360 \pst@solides@resolution\space div} bind def
         /PHI 0 def
         /tableau_des_sommets [
          0 dt@ 360 dt@ sub{/t@ exch def
                    /PHI t@ def /THETA0 THETA def
                     x@ y@ z@
                     /PHI t@ dt@ add def /THETA1 THETA def
                     x@ y@ z@ %/x1 x def /y1 y def /z1 z def % S2
                     /PHI PHI dPHI add def
                     rm ri THETA1 cos mul add PHI cos mul
                     rm ri THETA1 cos mul add PHI sin mul
                     ri THETA1 sin mul                 % S3
                     /PHI PHI dt@ sub def
                     rm ri THETA0 cos mul add PHI cos mul
                     rm ri THETA0 cos mul add PHI sin mul
                     ri THETA0 sin mul  % S4
                  } for
                  ]
           def
         /Sommets {tableau_des_sommets aload pop} def
         /NbrePoints tableau_des_sommets length 3 div cvi def
        /Faces_internes  {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [ Ni Ni 1 add  Ni 2 add Ni 3 add]
                                     } for
              } def
        /Faces {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [Ni 3 add Ni 2 add Ni 1 add Ni]
                                     } for
             } def
} def
initvar_SpiralRing
}%
%\psSolid[object=new,sommets=Sommets,fillcolor=\psincolor,faces={Faces_internes}](#1,#2,#3)%
\psSolid[object=new,sommets=Sommets,faces={Faces},hollow](#1,#2,#3)%
  \endgroup%
  \ignorespaces}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ruban en helice spherique
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\def\psSphericalSpiral{\pst@object{psSphericalSpiral}}
%% usage : \psSphericalSpiral[options]
\def\psSphericalSpiral@i{\@ifnextchar({\psSphericalSpiral@ii}{\psSphericalSpiral@ii(0,0,0)}}
\def\psSphericalSpiral@ii(#1,#2,#3){%
  \pst@killglue%
  \begingroup%
  \use@par%
\pstVerb{%
/initvar_SpiralSpherical {
         /Rayon \pst@solides@R\space def
         /spires \pst@rubans@spires\space def
         /dPHI \pst@rubans@dPHI\space def
         /THETA {PHI spires 2 mul mul} def
         /x@ {Rayon THETA cos mul PHI cos mul} def
         /y@ {Rayon THETA sin mul PHI cos mul} def
         /z@ {Rayon PHI sin mul} def
         /dt@ {180 \pst@solides@resolution\space div} bind def
         /PHI -90 def
         x@ y@ z@ /x0 x@ def /y0 y@ def /z0 z@ def % S1
         /tableau_des_sommets [
          -90 dt@ 90 dPHI sub{/t@ exch def
                    /PHI t@ def /THETA0 THETA def
                     x@ y@ z@
                     /PHI t@ dt@ add def /THETA1 THETA def
                     x@ y@ z@ %/x1 x def /y1 y def /z1 z def % S2
                     /PHI PHI dPHI add def
%                     x1 y1 z                             % S3
                     Rayon THETA1 cos mul PHI cos mul
                     Rayon THETA1 sin mul PHI cos mul
                     z@
                     /PHI PHI dt@ sub def
                     Rayon THETA0 cos mul PHI cos mul
                     Rayon THETA0 sin mul PHI cos mul
                     z@  % S4
                  } for
                  ]
           def
         /Sommets {tableau_des_sommets aload pop} def
         /NbrePoints tableau_des_sommets length 3 div cvi def
        /Faces  {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [ Ni Ni 1 add  Ni 2 add Ni 3 add]
                                     } for
              } def
        /Faces_internes {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [Ni 3 add Ni 2 add Ni 1 add Ni]
                                     } for
             } def
} def
initvar_SpiralSpherical
}%
%\psSolid[object=new,sommets=Sommets,fillcolor=\psincolor,faces={Faces_internes}](#1,#2,#3)%
\psSolid[object=new,sommets=Sommets,faces={Faces},hollow](#1,#2,#3)%
  \endgroup%
  \ignorespaces%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ruban en helice sur un paraboloide
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\define@key[psset]{pst-rubans}{p}{\def\pst@rubans@p{#1}} % parametre de la parabole
\psset[pst-rubans]{p=2}

\def\psSpiralParaboloid{\pst@object{psSpiralParaboloid}}
%% usage : \psSpiralParaboloid[options]
\def\psSpiralParaboloid@i{\@ifnextchar({\psSpiralParaboloid@ii}{\psSpiralParaboloid@ii(0,0,0)}}
\def\psSpiralParaboloid@ii(#1,#2,#3){%
%  \pst@killglue%
  \begingroup%
  \use@par%
\pstVerb{%
         /dz@ \pst@rubans@dZ\space def % hauteur du ruban
         /p@ {\pst@rubans@p\space 2 mul} bind def % paramètre de la parabole x 2
         /Hauteur \pst@solides@h\space def
/initvar_SpiralParaboloid {
         /pulsation {6.28319 Hauteur div \pst@rubans@spires\space mul} bind def
         /x@ {z@ p@ mul sqrt t@ pulsation mul 57.295 mul cos mul} def
         /y@ {z@ p@ mul sqrt t@ pulsation mul 57.295 mul sin mul} def
         /dH {Hauteur \pst@solides@resolution\space div} bind def
         /tableau_des_sommets [
          0 dH Hauteur {/H@ exch def
                        /z@ H@ def
                        /t@ H@ def
                     x@ y@ z@   % S1
                       /t@ t@ dH add def
                       /z@ t@ def
                     x@ y@ z@   % S2
                     /z@ z@ dz@ add def
                     x@ y@ z@  % S3
                       /z@ H@ dz@ add def
                       /t@ H@ def
                     x@ y@ z@   % S4
                  } for
                  ]
           def
         /Sommets {tableau_des_sommets aload pop} def
         /NbrePoints tableau_des_sommets length 3 div cvi def
        /Faces  {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [ Ni Ni 1 add  Ni 2 add Ni 3 add]
                                     } for
              } def
        /Faces_internes {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [Ni 3 add Ni 2 add Ni 1 add Ni]
                                     } for
             } def
} def
initvar_SpiralParaboloid
}%
%\psSolid[object=new,sommets=Sommets,fillcolor=\psincolor,faces={Faces_internes}](#1,#2,#3)%
\psSolid[object=new,sommets=Sommets,faces={Faces},hollow](#1,#2,#3)%
  \endgroup%
  \ignorespaces%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\psSpiralCone{\pst@object{psSpiralCone}}
%% usage : \psSpiralCone[options](x,y,z)
\def\psSpiralCone@i{\@ifnextchar({\psSpiralCone@ii}{\psSpiralCone@ii(0,0,0)}}
\def\psSpiralCone@ii(#1,#2,#3){%
  \begingroup%
  \use@par%
\pstVerb{/dz \pst@rubans@dZ\space def
/initvar_SpiralHelice_Conique {
         /rubans \pst@rubans@rubans\space def
         /phase {360 rubans div} bind def
         /Rayon \pst@solides@R\space def
         /Hauteur \pst@solides@h\space def
         /PHI 0 def
         /t@0 Hauteur 2 div neg def
         /x@0 Rayon Hauteur 2 div div t@0 mul PHI cos mul def
         /y@0 Rayon Hauteur 2 div div t@0 mul PHI sin mul def
         /z@0 t@0 def
         /pulsation {6.28319 Hauteur div \pst@rubans@spires\space mul} bind def
         /x@1 {Rayon Hauteur 2 div div t@ mul t@ pulsation mul 57.295 mul PHI add cos mul} def
         /y@1 {Rayon Hauteur 2 div div t@ mul t@ pulsation mul 57.295 mul PHI add sin mul} def
         /z@1 {t@} def
         /dA {Hauteur \pst@solides@resolution\space div} bind def
         /tableau_des_sommets [
             rubans {
          Hauteur 2 div neg dA Hauteur 2 div {/t@ exch def
                   t@ abs dA gt {
                     x@0 y@0 z@0 % S0
                     x@1 y@1 z@1 % S1
                     /COEFF z@1 dz add z@1 div def
                     x@1 COEFF mul y@1 COEFF mul z@1 dz add % S2
                     x@0 COEFF mul y@0 COEFF mul z@0 dz add % S3
                     /x@0 x@1 def
                     /y@0 y@1 def
                     /z@0 z@1 def
                     } if
                  } for
          /PHI PHI phase add def
         /t@0 Hauteur 2 div neg def
         /x@0 Rayon Hauteur 2 div div t@0 mul PHI cos mul def
         /y@0 Rayon Hauteur 2 div div t@0 mul PHI sin mul def
         /z@0 t@0 def
          } repeat
                  ]
           def
         /Sommets {tableau_des_sommets aload pop} def
         /NbrePoints tableau_des_sommets length 3 div cvi def
        /Faces  {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [ Ni Ni 1 add  Ni 2 add Ni 3 add]
                                     } for
              } def
        /Faces_internes {0 4 NbrePoints 4 sub {
                 /Ni exch def
               [Ni 3 add Ni 2 add Ni 1 add Ni]
                                     } for
             } def
} def
initvar_SpiralHelice_Conique
}%
\psSolid[object=new,sommets=Sommets,faces={Faces},hollow](#1,#2,#3)%
  \endgroup%
  \ignorespaces%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\@=\PstAtCode\relax
\endinput