summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pst-ob3d/pst-ob3d.tex
blob: 3bd16decf80f91c8245b033ab3ae0e351822d911 (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
%%
%% This is file `pst-ob3d.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pst-ob3d.dtx  (with options: `pst-ob3d')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from pst-ob3d.tex.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file pst-ob3d.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%%
%% Package `pst-ob3d.dtx'
%%
%% Denis Girou (CNRS/IDRIS - France) <Denis.Girou@idris.fr>
%% Herbert Voss <hvoss@tug.org>
%%
%% August 22, 2007
%%
%% 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-ob3d' is a PSTricks package to draw basic three dimensional
%%   objects with various customizations.
%%
\def\fileversion{0.21}
\def\filedate{2007/08/22}
\message{`Pst-Objects3d' v\fileversion, \filedate\space (DG,hv)}
\csname PstObjectsThreeDLoaded\endcsname
\let\PstObjectsThreeDLoaded\endinput
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTthreeDLoaded\endinput\else\input pst-3d.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi
\input random.tex
\edef\PstAtCode{\the\catcode`\@}
\catcode`\@=11\relax
\pst@addfams{pst-ob3d}
\define@boolkey[psset]{pst-ob3d}[PstObjectsThreeD@]{OnlyVisibleFaces}[true]{}
\define@boolkey[psset]{pst-ob3d}[PstObjectsThreeD@]{RandomFaces}[true]{}
\define@boolkey[psset]{pst-ob3d}[PstObjectsThreeD@]{Corners}[true]{}
\define@key[psset]{pst-ob3d}{CornersColor}{\def\PstObjectsThreeD@CornersColor{#1}}
\define@key[psset]{pst-ob3d}{CornersLength}{%
  \def\PstObjectsThreeD@CornersLength{#1}%
  \def\PstObjectsThreeD@CornersLengthTmpA{#1}%
  \def\PstObjectsThreeD@CornersLengthTmpB{#1}}
\psset[pst-ob3d]{OnlyVisibleFaces=false,RandomFaces=false,
                Corners=false,CornersColor=black,CornersLength=0.15}
\def\PstCube{\@ifnextchar[{\PstCube@i}{\PstCube@i[]}}
\def\PstCube@i[#1]{\@ifnextchar({\PstCube@ii[#1]}{\PstCube@ii[#1](0,0,0)}}
\def\PstCube@ii[#1](#2,#3,#4)#5#6#7{{%
\psset{dimen=middle}%
\psset{#1}%
\ifnum\Pst@Debug=\@ne
  \def\PstObjectsThreeDFaceCenterA{A}%
  \def\PstObjectsThreeDFaceCenterB{B}%
  \def\PstObjectsThreeDFaceCenterC{C}%
  \def\PstObjectsThreeDFaceCenterD{D}%
  \def\PstObjectsThreeDFaceCenterE{E}%
  \def\PstObjectsThreeDFaceCenterF{F}%
\fi
\pst@expandafter\psget@@viewpoint\psk@viewpoint {} {} {} \@nil
\ifPstObjectsThreeD@Corners
  \let\PstObjectsThreeD@Shape\PstObjectsThreeD@Octogon
\else
  \let\PstObjectsThreeD@Shape\psframe
\fi
\ifdim\pst@dimc>\z@
  \ifdim\pst@dima>\z@
    \ifdim\pst@dimb>\z@
      \PstCube@DrawFaces{A}{E}{C}{B}{D}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
    \else
      \PstCube@DrawFaces{E}{D}{C}{A}{B}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
    \fi
  \else
    \ifdim\pst@dimb>\z@
      \PstCube@DrawFaces{A}{B}{C}{E}{D}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
    \else
      \PstCube@DrawFaces{D}{B}{C}{E}{A}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
    \fi
  \fi
\else
  \ifdim\pst@dima>\z@
    \ifdim\pst@dimb>\z@
      \PstCube@DrawFaces{B}{D}{C}{A}{E}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
    \else
      \PstCube@DrawFaces{A}{B}{C}{E}{D}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
    \fi
  \else
    \ifdim\pst@dimb>\z@
      \PstCube@DrawFaces{D}{E}{C}{A}{B}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
    \else
      \PstCube@DrawFaces{E}{A}{C}{D}{B}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
    \fi
  \fi
\fi}}
\def\PstDie{\@ifnextchar[{\PstDie@i}{\PstDie@i[]}}
\def\PstDie@i[#1]{\@ifnextchar({\PstDie@ii[#1]}{\PstDie@ii[#1](0,0,0)}}
\def\PstDie@ii[#1](#2,#3,#4){{%
\psset{dimen=middle}%
\psset{#1}%
\ifPstObjectsThreeD@RandomFaces
  \setrannum{\pst@cnth}{1}{6}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.5,.5)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.8,.8)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.5,.5)(.8,.8)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.2,.5)(.2,.8)(.8,.2)(.8,.5)(.8,.8)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.2,.8)(.5,.5)(.8,.2)(.8,.8)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.2,.8)(.8,.2)(.8,.8)}%
\else
  \def\PstObjectsThreeDFaceA{\psdots(.5,.5)}%
  \def\PstObjectsThreeDFaceB{\psdots(.2,.2)(.8,.8)}%
  \def\PstObjectsThreeDFaceC{\psdots(.2,.2)(.5,.5)(.8,.8)}%
  \def\PstObjectsThreeDFaceD{%
    \psdots(.2,.2)(.2,.5)(.2,.8)(.8,.2)(.8,.5)(.8,.8)}%
  \def\PstObjectsThreeDFaceE{\psdots(.2,.2)(.2,.8)(.5,.5)(.8,.2)(.8,.8)}%
  \def\PstObjectsThreeDFaceF{\psdots(.2,.2)(.2,.8)(.8,.2)(.8,.8)}%
\fi
\ifPstObjectsThreeD@Corners
\else
  \PstObjectsThreeD@OnlyVisibleFacestrue
\fi
\PstCube(#2,#3,#4){1}{1}{1}}}
\def\PstCube@DrawFaces#1#2#3#4#5#6#7#8{%
\ifPstObjectsThreeD@OnlyVisibleFaces
\else
  \bgroup
    \ifPstObjectsThreeD@Corners
      \psset{linecolor=\PstObjectsThreeD@CornersColor,
             fillcolor=\PstObjectsThreeD@CornersColor}%
    \fi
    \bgroup
      \ifPstObjectsThreeD@Corners
        \def\PstObjectsThreeD@CornersLengthTmpA{0}%
      \fi
      \expandafter\csname PstCube@DrawFace#1\endcsname#7#8
      \expandafter\csname PstCube@DrawFace#2\endcsname#7#8
    \egroup
    \bgroup
      \ifPstObjectsThreeD@Corners
        \def\PstObjectsThreeD@CornersLengthTmpB{0}%
      \fi
      \expandafter\csname PstCube@DrawFace#3\endcsname#7#8
    \egroup
  \egroup
\fi
\expandafter\csname PstCube@DrawFace#4\endcsname#7#8
\expandafter\csname PstCube@DrawFace#5\endcsname#7#8
\expandafter\csname PstCube@DrawFace#6\endcsname#7#8}
\def\PstCube@DrawFaceA(#1,#2,#3)(#4,#5,#6){%
\pst@dima=-#4\psxunit
\divide\pst@dima\tw@
\pst@dimc=#6\psyunit
\divide\pst@dimc\tw@
\ThreeDput[normal=0 -1 0](#1,#2,#3){%
  \PstObjectsThreeD@Shape(-#4,#6)
  \ifx\PstObjectsThreeDFaceA\@undefined
  \else
    \rput[bl](-#4,0){\PstObjectsThreeDFaceA}
  \fi
  \ifx\PstObjectsThreeDFaceCenterA\@undefined
  \else
    \rput[c](\pst@dima,\pst@dimc){\PstObjectsThreeDFaceCenterA}
  \fi}}
\def\PstCube@DrawFaceB(#1,#2,#3)(#4,#5,#6){%
\pst@dimb=#5\psxunit
\divide\pst@dimb\tw@
\pst@dimc=#6\psyunit
\divide\pst@dimc\tw@
\ThreeDput[normal=1 0 0](#1,#2,#3){%
  \PstObjectsThreeD@Shape(#5,#6)
  \ifx\PstObjectsThreeDFaceB\@undefined
  \else
    \rput[bl](0,0){\PstObjectsThreeDFaceB}
  \fi
  \ifx\PstObjectsThreeDFaceCenterB\@undefined
  \else
    \rput[c](\pst@dimb,\pst@dimc){\PstObjectsThreeDFaceCenterB}
  \fi}}
\def\PstCube@DrawFaceC(#1,#2,#3)(#4,#5,#6){%
\pst@dimg=-#4\psxunit
\advance \pst@dimg by #1\psxunit
\pst@dima=#4\psxunit
\divide\pst@dima\tw@
\pst@dimb=#5\psxunit
\divide\pst@dimb\tw@
\ThreeDput[normal=0 0 1](\pst@dimg,#2,#3){{%
  \psyunit=\psxunit
  \PstObjectsThreeD@Shape(#4,#5)
  \ifx\PstObjectsThreeDFaceC\@undefined
  \else
    \rput[bl](0,0){\PstObjectsThreeDFaceC}
  \fi
  \ifx\PstObjectsThreeDFaceCenterC\@undefined
  \else
    \rput[c](\pst@dima,\pst@dimb){\PstObjectsThreeDFaceCenterC}
  \fi}}}
\def\PstCube@DrawFaceD(#1,#2,#3)(#4,#5,#6){%
\pst@dimg=#5\psxunit
\advance \pst@dimg by #2\psyunit
\pst@dima=-#4\psxunit
\divide\pst@dima\tw@
\pst@dimc=#6\psyunit
\divide\pst@dimc\tw@
\ThreeDput[normal=0 -1 0](#1,\pst@dimg,#3){%
  \PstObjectsThreeD@Shape(-#4,#6)
  \ifx\PstObjectsThreeDFaceD\@undefined
  \else
    \rput[bl](-#4,0){\PstObjectsThreeDFaceD}
  \fi
  \ifx\PstObjectsThreeDFaceCenterD\@undefined
  \else
    \rput[c](\pst@dima,\pst@dimc){\PstObjectsThreeDFaceCenterD}
  \fi}}
\def\PstCube@DrawFaceE(#1,#2,#3)(#4,#5,#6){%
\pst@dimg=-#4\psxunit
\advance \pst@dimg by #1\psxunit
\pst@dimb=#5\psxunit
\divide\pst@dimb\tw@
\pst@dimc=#6\psyunit
\divide\pst@dimc\tw@
\ThreeDput[normal=1 0 0](\pst@dimg,#2,#3){%
  \PstObjectsThreeD@Shape(#5,#6)
  \ifx\PstObjectsThreeDFaceE\@undefined
  \else
    \rput[bl](0,0){\PstObjectsThreeDFaceE}
  \fi
  \ifx\PstObjectsThreeDFaceCenterE\@undefined
  \else
    \rput[c](\pst@dimb,\pst@dimc){\PstObjectsThreeDFaceCenterE}
  \fi}}
\def\PstCube@DrawFaceF(#1,#2,#3)(#4,#5,#6){%
\pst@dimg=-#4\psxunit
\advance \pst@dimg by #1\psxunit
\pst@dimh=#6\psyunit
\advance \pst@dimh by #3\psyunit
\pst@dima=#4\psxunit
\divide\pst@dima\tw@
\pst@dimb=#5\psxunit
\divide\pst@dimb\tw@
\ThreeDput[normal=0 0 1](\pst@dimg,#2,\pst@dimh){{%
  \psyunit=\psxunit
  \PstObjectsThreeD@Shape(#4,#5)
  \ifx\PstObjectsThreeDFaceF\@undefined
  \else
    \rput[bl](0,0){\PstObjectsThreeDFaceF}
  \fi
  \ifx\PstObjectsThreeDFaceCenterF\@undefined
  \else
    \rput[c](\pst@dima,\pst@dimb){\PstObjectsThreeDFaceCenterF}
  \fi}}}
\def\psget@@viewpoint#1 #2 #3 #4\@nil{%
\pssetxlength{\pst@dima}{#1}%
\pssetylength{\pst@dimb}{#2}%
\pssetzlength{\pst@dimc}{#3}}
\def\PstObjectsThreeD@Octogon(#1,#2){%
\pst@dimh=\PstObjectsThreeD@CornersLength pt
\multiply\pst@dimh#1
\pst@dimtonum{\pst@dimh}{\pst@tempa}%
\pst@dimh=\PstObjectsThreeD@CornersLengthTmpB pt
\multiply\pst@dimh#1
\pst@dimtonum{\pst@dimh}{\pst@tempg}%
\pst@dimh=\@ne pt
\advance\pst@dimh-\PstObjectsThreeD@CornersLength pt
\multiply\pst@dimh#1
\pst@dimtonum{\pst@dimh}{\pst@tempb}%
\pst@dimh=\@ne pt
\advance\pst@dimh-\PstObjectsThreeD@CornersLengthTmpA pt
\multiply\pst@dimh#1
\pst@dimtonum{\pst@dimh}{\pst@tempe}%
\pst@dimh=\PstObjectsThreeD@CornersLength pt
\multiply\pst@dimh#2
\pst@dimtonum{\pst@dimh}{\pst@tempc}%
\pst@dimh=\PstObjectsThreeD@CornersLengthTmpA pt
\multiply\pst@dimh#2
\pst@dimtonum{\pst@dimh}{\pst@tempf}%
\pst@dimh=\@ne pt
\advance\pst@dimh-\PstObjectsThreeD@CornersLength pt
\multiply\pst@dimh#2
\pst@dimtonum{\pst@dimh}{\pst@tempd}%
\pst@dimh=\@ne pt
\advance\pst@dimh-\PstObjectsThreeD@CornersLengthTmpB pt
\multiply\pst@dimh#2
\pst@dimtonum{\pst@dimh}{\pst@temph}%
\pspolygon(\pst@tempa,0)(\pst@tempe,0)(#1,\pst@tempf)(#1,\pst@tempd)
          (\pst@tempb,#2)(\pst@tempg,#2)(0,\pst@temph)(0,\pst@tempc)}
\def\PstDie@Letter#1#2{%
\advance#1\@ne
\ifnum#1>6
  #1=\@ne
\fi
\def#2{\ifcase#1\or A\or B\or C\or D\or E\or F\fi}}
\catcode`\@=\PstAtCode\relax
\endinput
%%
%% End of file `pst-ob3d.tex'.