Debian Codegraph @

texmf-dist/doc/generic/pst-solides3d/text/par-image2d-en.tex

raw
1 \section{Projection of images}
2
3
4 This command displays an eps image on a plane defined by an origin and a normal, this plan can be the face
5 of a predefined object: a cube for example. The eps image must be prepared according to the method
6 described in the documentation for
7 `\textsf{pst-anamorphosis'}\footnote{\url{http://melusine.eu.org/syracuse/G/pst-anamorphosis/doc/}}.
8
9 The macro includes various options:
10 \begin{verbatim}
11 \psImage[filename=<filename with extension>,
12 divisions=10,
13 normale=nx ny nz,
14 origine=xO yO zO,
15 phi=angle,
16 unitPicture=28.45](x,y)
17 \end{verbatim}
18 It focuses the image on the plane at the point defined by the origin, it may be moved to another point
19 by setting the \emph{optional} values \verb+(x,y)+. You can omit these values
20 if we do not translate the image into another point than the origin of the plan.
21
22 \psframebox[linestyle=none,fillcolor=yellow,fillstyle=solid]{\texttt{divisions=20}}
23 selects the number of sub-segments for \texttt{lineto} in the image file to display. The higher the number,
24 the higher the projected image will be faithful to the original. However, the projection takes place on a
25 plane, the deformation will be small in all cases except one approaches very close to the plane, therefore
26 a small number of sub-divisions will generally give a correct result and will perform calculations quickly .
27
28 \psframebox[linestyle=none,fillcolor=yellow,fillstyle=solid]{\texttt{phi}} can rotate the image of a fixed
29 value in degrees.
30
31 \psframebox[linestyle=none,fillcolor=yellow,fillstyle=solid]{\texttt{unitImage=28.45}}
32 allows to resize the size of the eps image that is generally points per cm, a larger value will give a smaller image.
33
34 If you want to place the image on the front of an object, it will follow the following procedure:
35 \begin{itemize}
36 \item determine the number of faces of the object, see the documentation of `\textsf{pst-solides3d} ';
37 \item give to the normal of the face in question and origin at the center of that face. We can always
38 shift the image with \verb+(x, y)+.
39 \end{itemize}
40
41 \begin{verbatim}
42 \begin{pspicture}(-5,-5)(5,5)
43 \psset{solidmemory}
44 \psSolid[object=cube,a=8,action=draw,name=OBJECT,linecolor=red]%
45 \psImage[filename=tiger.eps,normal=OBJECT 0 solidnormaleface,
46 origine=OBJECT 0 solidcentreface,unitPicture=75]
47 \psImage[filename=tiger.eps,normal=OBJECT 1 solidnormaleface,
48 origine=OBJECT 1 solidcentreface,unitPicture=75]
49 \psImage[filename=tiger.eps,normal=OBJECT 4 solidnormaleface,
50 origine=OBJECT 4 solidcentreface,unitPicture=75]
51 \psImage[filename=tiger.eps,normal=OBJECT 3 solidnormaleface,
52 origine=OBJECT 3 solidcentreface,unitPicture=75]
53 \psImage[filename=tiger.eps,normal=OBJECT 2 solidnormaleface,
54 origine=OBJECT 2 solidcentreface,unitPicture=75]
55 \end{pspicture}
56 \end{verbatim}
57
58 If the selected plan is not visible to the set position, it may, if desired, force the display of the
59 image with the \verb+visibility+.
60
61
62
63 \begin{pspicture}(-10,-4)(6,13)
64 \psframe(-10,-4)(6,13)
65 \psset{viewpoint=12 60 20 rtp2xyz,Decran=10,lightsrc=viewpoint}
66 \psImage[filename=images/tiger.eps,normal=1 0 0,origine=0 2 2](0,3)
67 \psSolid[object=plan,
68 definition=normalpoint,
69 args={0.01 2 2 [1 0 0 90]},
70 action=draw,linecolor=red,
71 planmarks,
72 showBase,
73 base=-2 2 -2 4]
74 \psImage[filename=images/tiger.eps,normal=0 1 0,origine=2 0 2]%(0,0)
75 \psSolid[object=plan,
76 definition=normalpoint,
77 args={2 0.01 2 [0 1 0 180]},
78 action=draw,linecolor=red,
79 planmarks,
80 showBase,
81 base=-2 2 -2 2]
82 \psImage[filename=images/tiger.eps,normal=0 0 1,origine=2 2 0](2,0)
83 \psSolid[object=plan,
84 definition=normalpoint,
85 args={2 2 0.01 [0 0 1 90]},
86 action=draw,linecolor=red,
87 planmarks,
88 showBase,
89 base=-2 3 -2 2]%
90 \psImage[filename=images/parrot.eps,normal=1 1 1,origine=5 5 5,unitPicture=75,phi=90]%(0,0)
91 \psSolid[object=plan,
92 definition=normalpoint,
93 args={5 5 5 [1 1 1 180]},
94 action=draw,linecolor=red,
95 planmarks,
96 showBase,
97 base=-2 2 -2 2]
98 \axesIIID(0,0,0)(4,5,6)
99 \end{pspicture}
100
101
102 \psset{unit=1cm}
103 \psset{viewpoint=20 -120 30 rtp2xyz,Decran=20,unitPicture=15,lightsrc=viewpoint}
104 \begin{pspicture}[solidmemory](-5,-7.5)(7,6)
105 \psSolid[object=cube,a=8,name=OBJECT,linecolor=red,fillcolor=white%,numfaces=all,fontsize=100
106 ]
107 \psset[pst-solides3d]{normal=OBJECT 0 solidnormaleface}
108 \psImage[filename=images/tiger.eps,origine=OBJECT 0 solidcentreface,phi=-90](0,0)
109 %\psset[pst-solides3d]{normal=OBJECT 1 solidnormaleface}
110 %\psImage[filename=images/tiger.eps,
111 % origine=OBJECT 1 solidcentreface]
112 %\psset[pst-solides3d]{normal=OBJECT 4 solidnormaleface}
113 %\psImage[filename=images/tiger.eps,origine=OBJECT 4 solidcentreface]
114 \psset[pst-solides3d]{normal=OBJECT 3 solidnormaleface}
115 \psImage[filename=images/tiger.eps,origine=OBJECT 3 solidcentreface]
116 \psset[pst-solides3d]{normal=OBJECT 2 solidnormaleface}
117 \psImage[filename=images/tiger.eps,origine=OBJECT 2 solidcentreface]
118 \end{pspicture}
119
120
121
122 \section{A bit of theory}
123
124 \begin{minipage}{.45\textwidth}
125 The image is projected into a plane defined by a normal $\vec{K}$ and origin $O'(x_O,y_O,z_O)$.
126 The coordinates of points in each image are given in reference to a benchmark plan
127 $(O,\vec {I},\vec{J})$ whose vectors are determined from $\vec{K}$ as follows:
128 This vector $\vec{K}$ is defined by $\theta$ and $\varphi$, we calculate these values from the coordinates.
129 With $(O,\vec{i},\vec{j},\vec{k})$
130
131 \begin{align*}
132 \vec{K}=\left(
133 \begin{aligned}
134 \cos\varphi & \cos\theta\\
135 \cos\varphi & \sin\theta\\
136 \sin\varphi
137 \end{aligned}%
138 \right)
139 \end{align*}
140
141 You must then choose the other two basis vectors
142 $(\vec{I},\vec{J},\vec{K})$.
143 I choose to keep $\vec{I}$ at the plane $Oxy$
144 \end{minipage}
145 %
146 \hfill
147 %
148 \begin{minipage}{0.45\textwidth}
149 \begin{pspicture}(-3,-5)(4,5)
150 \psset{unit=5}
151 \psset{viewpoint=50 15 20 rtp2xyz ,Decran=35}
152 \psset{solidmemory}
153 \pstVerb{/Theta 45 def /Phi 45 def
154 /cosPhi {Phi cos} bind def
155 /sinPhi {Phi sin} bind def
156 /cosTheta {Theta cos} bind def
157 /sinTheta {Theta sin} bind def
158 /Kx {cosPhi cosTheta mul} bind def
159 /Ky {cosPhi sinTheta mul} bind def
160 /Kz sinPhi def}%
161 \psSolid[object=plan,definition=normalpoint,args={0 0 0 [Kx Ky Kz 145]},action=draw,linecolor=blue,base=-1 1 -1 0]
162 \psSolid[object=plan,definition=normalpoint,args={0 0 0 [0 0 1]},action=draw**,linecolor=red,base=-1 1 -1 1]
163 \axesIIID(0,0,0)(1.25,1.25,1.25)
164 \psSolid[object=plan,definition=normalpoint,args={0 0 0 [0 0 1]},action=none,linecolor=red,name=Oxy,base=-1 1 -1 1]
165 \psset{plan=Oxy}%
166 \psProjection[object=cercle,resolution=360,args=0 0 1,linecolor=gray,linestyle=dashed,range=0 360]
167 \psProjection[object=texte,text=q,fontsize=5,PSfont=Symbol,isolatin=false,phi=90](.25,0.125)%
168 \psSolid[object=plan,
169 definition=normalpoint,
170 args={0 0 0 [1 -1 0]},
171 action=none,linecolor=red,
172 name=Oxz,
173 base=-1 1 -1 1
174 ]%
175 \psset{plan=Oxz}%
176 \psProjection[object=cercle,resolution=360,
177 args=0 0 1,linecolor=gray,
178 linestyle=dashed,
179 range=0 90]%
180 \psSolid[object=vecteur,
181 definition={[.02 .1]},
182 linecolor={[cmyk]{1,0,1,0.5}},
183 args=Kx Ky Kz](0,0,0)
184 \psSolid[object=plan,
185 definition=normalpoint,
186 args={0 0 0 [Kx Ky Kz 145]},
187 action=draw,linecolor=blue,
188 base=-1 1 0 1,name=projection]%
189 \psProjection[object=texte,plan=projection,text=plan de projection,fontsize=4](0,0.85)%
190 \psSolid[object=vecteur,
191 definition={[.02 .1]},
192 linecolor=red,
193 args=sinTheta neg cosTheta 0 ](0,0,0)%
194 \psSolid[object=plan,
195 definition=normalpoint,
196 args={0 0 0 [sinTheta cosTheta neg 0]},
197 action=none,linecolor=blue,
198 base=-1 1 -1 1,name=verticale]%
199 \psProjection[object=texte,text=f,plan=verticale,PSfont=Symbol,isolatin=false,fontsize=4](0.5,0.2)%
200 \psSolid[object=vecteur,
201 definition={[.02 .1]},
202 linecolor=blue,
203 args=cosTheta neg sinPhi mul sinTheta neg sinTheta mul cosPhi ](0,0,0)%
204 \psPoint(Kx, Ky,Kz){K}
205 \psPoint(Kx, Ky,0){XY}
206 \psPoint(Kx,0,0){X}
207 \psPoint(0, Ky,0){Y}
208 \psPoint(0,0,0){O}
209 \psPoint(cosTheta neg sinPhi mul, sinTheta neg sinTheta mul, cosPhi){J}
210 \psPoint(sinTheta neg, cosTheta, 0){I}
211 \psline(O)(XY)
212 \psline[linestyle=dashed](XY)(K)
213 \psline(X)(XY)(Y)
214 \pstVerb{/xTube {t Cos 0.4 mul} def /yTube {t Sin 0.4 mul} def /zTube {0} def}%
215 \defFunction{F}(t){xTube}{yTube}{zTube}%
216 % choix de deux points très voisins sur le tube
217 \pstVerb{/t1 0.22 pi mul def /t2 0.25 pi mul def }%
218 \psPoint(/t t1 def xTube ,yTube,zTube){A}
219 \psPoint(/t t2 def xTube ,yTube,zTube){B}
220 \psSolid[object=courbe,
221 r=0,
222 function=F,
223 range=0 0.25 pi mul,
224 fillcolor=red]
225 \psline[linecolor=red,arrowsize=0.03]{->}(A)(B)
226 %
227 \pstVerb{/xT {t Cos 0.4 mul cosPhi mul} def /yT {t Cos 0.4 mul cosPhi mul} def /zT {t Sin 0.4 mul} def}%
228 \defFunction{F}(t){xT}{yT}{zT}%
229 % choix de deux points très voisins sur le tube
230 \pstVerb{/t1 0.22 pi mul def /t2 0.25 pi mul def }%
231 \psPoint(/t t1 def xT ,yT,zT){A}
232 \psPoint(/t t2 def xT ,yT,zT){B}
233 \psSolid[object=courbe,
234 r=0,
235 function=F,
236 range=0 0.25 pi mul,
237 fillcolor={[rgb]{0.3,0.18,0.18}}]
238 \psline[linecolor={[rgb]{0.3,0.18,0.18}},arrowsize=0.03]{->}(A)(B)
239 \uput[u](J){\blue$\overrightarrow{J}$}
240 \uput[ur](K){\color[cmyk]{1,0,1,0.5}{$\overrightarrow{K}$}}
241 \uput[r](I){\red$\overrightarrow{I}$} %$
242 \end{pspicture}
243 \end{minipage}
244
245 \endinput
246
247
248
249 Seen from above, in the plane $Oxy$:
250
251 \begin{minipage}{.4\textwidth}
252 \[
253 \overrightarrow{I}=\left(%
254 \begin{aligned}
255 -\sin\theta\\
256 \hphantom{-}\cos\theta\\
257 0
258 \end{aligned}
259 \right)
260 \]
261 \end{minipage}
262 \hfill
263 \begin{minipage}{0.5\textwidth}
264
265 \begin{pspicture}(-3,-4)(4,2)
266 \psline{->}(4,0)\uput[0](4,0){$y$}
267 \psline[linestyle=dashed](0,2)
268 \psline{->}(0,-3.5)\uput[270](0,-3.5){$x$}
269 \uput[135](0,0){O}
270 {\psset{linewidth=2\pslinewidth}
271 \psline{->}(0,-2)\uput[0](0,-2){$\overrightarrow{i}$}
272 \psline{->}(2,0)\uput[90](2,0){$\overrightarrow{j}$}
273 \psline[linestyle=dotted](3;-30)\uput[0](3;-30){$x'$}
274 \psline[linecolor=red,doubleline=true]{->}(2;60)\uput[0](2;60){$\red \overrightarrow{I}$}
275 }
276 \psarc{->}(0,0){1.5}{-90}{-30}\uput[0](1.6;-60){$\theta$}
277 \end{pspicture}
278 \end{minipage}
279
280 Il reste à trouver $\overrightarrow{J}$ pour que la base
281 ($\overrightarrow{I},\overrightarrow{J},\overrightarrow{K}$) soit directe :
282 $\overrightarrow{J}=\overrightarrow{K}\times\overrightarrow{I}$
283 \[
284 \overrightarrow{J}=\left(\begin{aligned}
285 \cos\varphi\cos\theta\\
286 \cos\varphi\sin\theta\\
287 \sin\varphi
288 \end{aligned}
289 \right)
290 \times
291 \left(
292 \begin{aligned}{c}
293 -\sin\theta\\
294 \hphantom{-}\cos\theta\\
295 0
296 \end{aligned}
297 \right)
298 =
299 \left(\begin{aligned}
300 -\sin\varphi\cos\theta\\
301 -\sin\varphi\sin\theta\\
302 \cos\varphi
303 \end{aligned}
304 \right)
305 \]
306 The transformation matrice:
307 \[
308 A=\left(%
309 \begin{array}{ccc}
310 -\sin\theta&-\sin\varphi\cos\theta&\cos\varphi\cos\theta\\
311 \hphantom{-}\cos\theta&-\sin\varphi\sin\theta&\cos\varphi\sin\theta\\
312 0&\cos\varphi&\sin\varphi
313 \end{array}
314 \right)
315 \]
316
317 to determine the coordinates ($ x, y, z $) of a point $M$ if one knows its
318 coordinates $(X, Y, Z)$ in the reference
319 $(O,\overrightarrow{I},\overrightarrow{J},\overrightarrow{K})$.
320
321 \[
322 \left(\begin{aligned}{c}
323 x\\
324 y\\
325 z
326 \end{aligned}
327 \right)
328 =\left(%
329 \begin{array}{ccc}
330 -\sin\theta&-\sin\varphi\cos\theta&\cos\varphi\cos\theta\\
331 \hphantom{-}\cos\theta&-\sin\varphi\sin\theta&\cos\varphi\sin\theta\\
332 0&\cos\varphi&\sin\varphi
333 \end{array}
334 \right)
335 \left(\begin{aligned}
336 X\\
337 Y\\
338 Z
339 \end{aligned}
340 \right)
341 \]
342 \[
343 \left\lbrace\begin{array}{cccclcl}
344 x&=&-X\sin\theta&-&Y\sin\varphi\cos\theta&+&Z\cos\varphi\cos\theta\\
345 y&=&\hphantom{-}X\cos\theta&-&Y\sin\varphi\sin\theta&+&Z\cos\varphi\sin\theta\\
346 z&=&0&+&Y\cos\varphi&+&Z\sin\varphi
347 \end{array}
348 \right.
349 \]
350
351 If we consider a point on the plane in the plane $XOY$
352
353 \[
354 \left\lbrace\begin{array}{ccccl}
355 x&=&-X\sin\theta&-&Y\sin\varphi\cos\theta\\
356 y&=&\hphantom{-}X\cos\theta&-&Y\sin\varphi\sin\theta\\
357 z&=&0&+&Y\cos\varphi
358 \end{array}
359 \right.
360 \]
361 Et si maintenant, ce repère $OXYZ$ est translaté en un point
362 $O'(x_{O'},y_{O'},z_{O'})$
363 \[
364 \left\lbrace\begin{array}{cccclcl}
365 x&=&-X\sin\theta&-&Y\sin\varphi\cos\theta&+&x_{O'}\\
366 y&=&\hphantom{-}X\cos\theta&-&Y\sin\varphi\sin\theta&+&y_{O'}\\
367 z&=&0&+&Y\cos\varphi&+&z_{O'}
368 \end{array}
369 \right.
370 \]
371
372 Remarks:
373 \begin{itemize}
374 \item $\overrightarrow{K}$ since we can obviously choose another associated base $ (\overrightarrow {I},
375 \overrightarrow {J}) $ by turning the previously calculated around $ \overrightarrow {K} $ of the selected angle.
376 For this first draft order I preferred to rotate the image, which probably has the disadvantage lengthen calculations \ldots\
377
378 \item Jean-Paul Vigneault made a different choice for the base $(\overrightarrow{I}, \overrightarrow{J} $,
379 he calculated $ \overrightarrow {J}$ from $\overrightarrow {K} $ by relation:
380 \[
381 \overrightarrow{J}=\overrightarrow{K}\wedge \left(%
382 \begin{array}{c}
383 1\\
384 0\\
385 0
386 \end{array}
387 \right)
388 \]
389 $\overrightarrow{I}=\overrightarrow{J}\wedge\overrightarrow{K}$.
390 We can bring the system defined in `\textsf{pst-solides3d}' to the one I chose by setting the \textsf{phi}
391 of `\textsf{pst-solides3d}' (which allows you to turn the mark ) the proper value \ldots\ to calculate.
392
393 \end{itemize}
394