571b1654f11ae59d3b48141b264361885d8a081a
[pst-anamorphosis.git] / doc / possible_extensions.tex
1 \documentclass[12pt]{article}
2 \usepackage{pst-anamorphosis-add,pst-plot}
3 \usepackage[T1]{fontenc}
4 \usepackage[ansinew]{inputenc}
5 \usepackage{amsmath,amssymb}
6 \usepackage[a4paper]{geometry}
7
8 \makeatletter
9 \def\psparametricplotA{\pst@object{parametricplotA}}% hv 2008-11-22
10 \def\parametricplotA{\pst@object{parametricplotA}}
11 \def\parametricplotA@i#1#2{\@ifnextchar[{\parametricplotA@x{#1}{#2}}{\parametricplotA@x{#1}{#2}[]}}
12 \def\parametricplotA@x#1#2[#3]{\@ifnextchar[{\parametricplotA@xi{#1}{#2}[#3]}{\parametricplotA@xi{#1}{#2}[#3][]}}
13 \def\parametricplotA@xi#1#2[#3][#4]#5{%
14 \pst@killglue%
15 \begingroup%
16 \use@par%
17 \@nameuse{beginplot@\psplotstyle}%
18 \addto@pscode{%
19 \tx@optionsanamorphosis
20 \tx@optionsanamorphosisAdd
21 #3 %prefix PS code
22 \psplot@init
23 /t #1 def
24 /t1 #2 def
25 /dt t1 t sub \psk@plotpoints div def
26 /F@pstplot \ifPst@algebraic (#5)
27 \ifx\psk@PlotDerivative\@none\else
28 \psk@PlotDerivative\space { (t) tx@Derive begin Derive end } repeat
29 \fi\space
30 tx@AlgToPs begin AlgToPs end cvx
31 \else { #5 } \fi def
32 \ifPst@VarStep
33 /StillZero 0 def /LastNonZeroStep dt def
34 /F2@pstplot tx@Derive begin (#5) (t) Derive (t) Derive end
35 \ifx\psk@PlotDerivative\@none\else
36 \psk@PlotDerivative\space { (t) tx@Derive begin Derive end } repeat
37 \fi\space
38 tx@AlgToPs begin AlgToPs end cvx def
39 %% computation of the tolerance defined by plotpoints
40 /epsilon12 \ifx\psk@VarStepEpsilon\@default
41 tx@Derive begin F2@pstplot end Pyth
42 dt 3 exp abs mul
43 \else\psk@VarStepEpsilon\space 12 mul \fi def
44 /ComputeStep {
45 dup 1e-4 lt
46 { pop StillZero 2 ge { LastNonZeroStep 2 mul } { LastNonZeroStep } ifelse /StillZero StillZero 1 add def }
47 { epsilon12 exch div 1 3 div exp /StillZero 0 def }
48 ifelse } bind def
49 \fi
50 /xy {
51 \ifPst@algebraic F@pstplot \else #5 \fi
52 \pst@number\psyunit mul exch
53 \pst@number\psxunit mul exch
54 tx@anamorphosisPathDict begin Anamorphose end
55 } def
56 }%
57 \gdef\psplot@init{}%
58 \@pstfalse
59 \@nameuse{testqp@\psplotstyle}%
60 \if@pst\parametricplotA@ii{#4}\else\parametricplotA@iii{#4}\fi
61 \endgroup%
62 \ignorespaces}
63 %
64 \def\parametricplotA@ii#1{% para is the post code
65 \ifPst@VarStep%
66 \addto@pscode{%
67 mark xy \@nameuse{beginqp@\psplotstyle}
68 { F2@pstplot Pyth ComputeStep
69 t 2 copy add dup t1 gt {pop t1} if /t exch def F2@pstplot Pyth ComputeStep
70 /t 3 -1 roll def 2 copy gt { exch } if pop
71 /t t 3 -1 roll add dup t1 gt {pop t1} if def
72 xy \@nameuse{doqp@\psplotstyle}
73 t t1 eq { exit } if } loop}%
74 \else\pst@killglue%
75 \addto@pscode{%
76 /ps@Exit false def
77 xy \@nameuse{beginqp@\psplotstyle}
78 \psk@plotpoints 1 sub {
79 /t t dt add def
80 xy \@nameuse{doqp@\psplotstyle}
81 ps@Exit { exit } if
82 } repeat
83 ps@Exit not {
84 /t t1 def
85 xy \@nameuse{doqp@\psplotstyle}
86 } if
87 }%
88 \fi%
89 \addto@pscode{ #1 }%
90 \@nameuse{endqp@\psplotstyle}}
91 %
92 \def\parametricplotA@iii#1{%
93 \ifPst@VarStep%
94 \addto@pscode{%
95 /n 2 def
96 mark
97 { xy n 2 roll F2@pstplot Pyth
98 ComputeStep t 2 copy add dup t1 gt {pop t1} if
99 /t exch def F2@pstplot Pyth ComputeStep
100 /t 3 -1 roll def 2 copy gt { exch } if pop
101 /t t 3 -1 roll dup /LastNonZeroStep exch def add dup t1 gt {pop t1} if def /n n 2 add def
102 t t1 eq { exit } if } loop
103 xy n 2 roll}%
104 \else\pst@killglue%
105 \addto@pscode{
106 mark
107 /n 2 def
108 \psk@plotpoints {
109 xy
110 n 2 roll
111 /n n 2 add def
112 /t t dt add def
113 } repeat
114 /t t1 def
115 xy
116 n 2 roll}%
117 \fi%
118 \addto@pscode{ #1 }%
119 \@nameuse{endplot@\psplotstyle}}
120 %
121 %%%%%%%\psframeA ---------------------
122 \def\psframeA{\pst@object{psframeA}}
123 \def\psframeA@i(#1){%
124 \@ifnextchar({\psframeA@ii(#1)}{\psframeA@ii(0,0)(#1)}}
125 \def\psframeA@ii(#1)(#2){%
126 \begin@ClosedObj
127 \pst@getcoor{#1}\pst@tempa%
128 \pst@@getcoor{#2}%
129 \def\pst@linetype{2}%
130 \addto@pscode{%
131 \tx@optionsanamorphosis
132 \tx@optionsanamorphosisAdd
133 \pst@tempa
134 \pst@coor
135 /Y2 ED
136 /X2 ED
137 /Y1 ED
138 /X1 ED
139 X1 Y1 tx@anamorphosisPathDict begin Anamorphose end
140 moveto
141 0 0.005 1.0 { %(X1,Y1)->(X2,Y1)
142 /K exch def
143 K X2 mul 1 K sub X1 mul add
144 Y1
145 tx@anamorphosisPathDict begin Anamorphose end
146 lineto
147 } for
148 0 0.005 1.0 { % (X2,Y1)->(X2,Y2)
149 /K exch def
150 X2
151 K Y2 mul 1 K sub Y1 mul add
152 tx@anamorphosisPathDict begin Anamorphose end
153 lineto
154 } for
155 0 0.005 1.0 { % (X2,Y2)->(X1,Y2)
156 /K exch def
157 K X1 mul 1 K sub X2 mul add
158 Y2
159 tx@anamorphosisPathDict begin Anamorphose end
160 lineto
161 } for
162 0 0.005 1.0 { % (X1,Y2)->(X1,Y1)
163 /K exch def
164 X1
165 K Y1 mul 1 K sub Y2 mul add
166 tx@anamorphosisPathDict begin Anamorphose end
167 lineto
168 } for
169 }%
170 \showpointsfalse
171 \end@ClosedObj}
172 %
173 %%%%%%%\translateA ---------------------------
174 \def\translateA{\def\pst@par{}\pst@object{translateA}}
175 \def\translateA@i(#1){{%
176 \pst@@getcoor{#1}%
177 \addto@pscode{
178 \tx@optionsanamorphosis
179 \tx@optionsanamorphosisAdd
180 \pst@coor
181 tx@anamorphosisPathDict begin Anamorphose end
182 translate}}}%
183 %
184
185 \title{pst-anamorphosis : extensions possibles}
186 \author{Jürgen Gilg, Manuel Luque, Jean-Michel Sarlat}
187 \date{21 octobre 2011}
188 \begin{document}
189 \maketitle
190 \begin{abstract}
191 Il est relativement facile d'adapter les commandes de \textsf{PStricks} à \textsf{pst-anamorphosis}. C'est ainsi que la plupart des macros de \textsf{pst-anamorphosis-add} sont des adaptations de celles de \textsf{PStricks}. Toutes ne l'on pas été pour ne pas alourdir inutilement le package. Nous allons détailler sur un exemple la façon de procéder.
192
193 Remarque : toutes les macros ne sont pas adaptables, cela serait le cas si les anamorphoses transformaient une ligne droite en une ligne droite. Or, à part la perspective, ce n'est pas le cas. En conséquence, \verb+\psline+, \verb+\psframe+, \verb+\pspolygon+ doivent être réécrits en divisant le segment initial en un grand nombre de petits segments : pour \verb+\pslineA+ par exemple chaque segment initial est divisé en 200 parties et ceci quelle que soit sa longueur, dans l'idéal il faudrait tenir compte de la longueur du segment avant de choisir le nombre de segmentations.
194 \end{abstract}
195 \section{\textbackslash{}psparametricplotA}
196 \subsection{Adaptation}
197 À partir d'une copie de \textbackslash{}\textsf{psparametricplot} :
198 \begin{enumerate}
199 \item On remplace parout \textsf{psparametricplot} par \textsf{psparametricplotA} ;
200 \item dans le premier \verb+\addto@pscode{%+
201 \begin{verbatim}
202 \addto@pscode{%
203 \tx@optionsanamorphosis
204 \tx@optionsanamorphosisAdd
205 #3 %prefix PS code
206 \psplot@init
207 \end{verbatim}
208 on introduit juste au début les variables de \textsf{pst-anamorphosis} ;
209 \item et pour terminer dans \verb+/xy {+:
210 \begin{verbatim}
211 /xy {
212 \ifPst@algebraic F@pstplot \else #5 \fi
213 \pst@number\psyunit mul exch
214 \pst@number\psxunit mul exch
215 tx@anamorphosisPathDict begin Anamorphose end
216 } def
217 \end{verbatim}
218 on insère à la fin les calculs propres à l'anamorphose. C'est terminé, la macro est opérationnelle !
219 \end{enumerate}
220 \subsection{Exemple}
221 \begin{center}
222 \begin{pspicture}(-6,-6)(6,6)
223 \pscircle[doubleline=true]{3}
224 \psset{type=conical}
225 \pscircle[linecolor=blue](0,0){1}
226 \pscircleA[linecolor=blue](0,0){1}
227 \pscircle[linecolor=blue](0,0){2}
228 \pscircleA[linecolor=blue](0,0){2}
229 \psframeA[linecolor=blue,fillstyle=solid,fillcolor=cyan](1,1)(2,2)
230 \psframeA[linecolor=blue,fillstyle=solid,fillcolor=cyan](-1,-1)(-2,-2)
231 \psframeA[linecolor=blue,fillstyle=solid,fillcolor=cyan](-1,1)(-2,2)
232 \psframeA[linecolor=blue,fillstyle=solid,fillcolor=cyan](1,-1)(2,-2)
233 \psframe[linecolor=blue,fillstyle=solid,fillcolor=cyan](1,1)(2,2)
234 \psframe[linecolor=blue,fillstyle=solid,fillcolor=cyan](-1,-1)(-2,-2)
235 \psframe[linecolor=blue,fillstyle=solid,fillcolor=cyan](-1,1)(-2,2)
236 \psframe[linecolor=blue,fillstyle=solid,fillcolor=cyan](1,-1)(2,-2)
237 \parametricplotA[plotpoints=3600,linecolor=red,linewidth=1mm]{0}{360}{%
238 /Radius 1.5 0.5 t 10 mul sin mul add def
239 Radius t cos mul
240 Radius t sin mul
241 }
242 \parametricplot[plotpoints=3600,linecolor=red,linewidth=1mm]{0}{360}{%
243 /Radius 1.5 0.5 t 10 mul sin mul add def
244 Radius t cos mul
245 Radius t sin mul
246 }
247 \multido{\n=0.5+0.5,\N=0.5+0.5}{4}{%
248 \pnode(! \n\space -2){A}
249 \pnode(! \n\space 2){B}
250 \psline(A)(B)
251 \pslineA(A)(B)
252 \pnode(!-2 \N){A}
253 \pnode(!2 \N){B}
254 \pslineA(A)(B)
255 \psline(A)(B)
256 }
257 \multido{\n=-2.0+0.5,\N=-2.0+0.5}{4}{%
258 \pnode(! \n\space -2){A}
259 \pnode(! \n\space 2){B}
260 \psline(A)(B)
261 \pslineA(A)(B)
262 \pnode(!-2 \N){A}
263 \pnode(!2 \N){B}
264 \pslineA(A)(B)
265 \psline(A)(B)
266 }
267 \psline(-2,0)(2,0)
268 \psline(0,-2)(0,2)
269 \pslineA(0,-2)(0,-0.5)
270 \pslineA(0,2)(0,0.5)
271 \pslineA(-2,0)(-0.5,0)
272 \pslineA(2,0)(0.5,0)
273 \psdot[dotstyle=x,dotsize=.2](0,0)
274 \end{pspicture}
275 \end{center}
276 \begin{verbatim}
277 \parametricplotA[plotpoints=3600,linecolor=red,linewidth=1mm]{0}{360}{%
278 /Radius 1.5 0.5 t 10 mul sin mul add def
279 Radius t cos mul
280 Radius t sin mul
281 }
282 \parametricplot[plotpoints=3600,linecolor=red,linewidth=1mm]{0}{360}{%
283 /Radius 1.5 0.5 t 10 mul sin mul add def
284 Radius t cos mul
285 Radius t sin mul
286 \end{verbatim}
287 \section{\textbackslash{}psframeA}
288 \verb+\psframeA(x1,y1)(x2,y2)+ a les mêmes propriétés que \verb+\psframe+
289 \begin{center}
290 \begin{pspicture}(-6,-6)(6,6.5)
291 \psset{type=conical,Rmirror=3}
292 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](-0.25,-0.25)(-0.01,-0.01)
293 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](-0.25,0.25)(-0.01,0.01)
294 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](0.01,0.01)(0.25,0.25)
295 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](0.01,-0.01)(0.25,-0.25)
296 \multido{\ry=-2.75+1,\rY=-2.25+1}{6}{
297 \multido{\n=-2.75+1.00,\N=-2.25+1.00}{7}{%
298 \psframeA[fillstyle=solid,fillcolor=red,linecolor=red](\n,\ry)(\N,\rY)}
299 }
300 \multido{\ry=-3.25+1,\rY=-2.75+1}{3}{
301 \multido{\n=-3.25+1.00,\N=-2.75+1.00}{7}{%
302 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](\n,\ry)(\N,\rY)}
303 }
304 \multido{\ry=0.75+1,\rY=1.25+1}{3}{
305 \multido{\n=-3.25+1.00,\N=-2.75+1.00}{7}{%
306 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](\n,\ry)(\N,\rY)}
307 }
308 \multido{\n=-3.25+1.00,\N=-2.75+1.00}{3}{%
309 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](\n,-0.25)(\N,0.25)}
310 \multido{\n=0.75+1.00,\N=1.25+1.00}{3}{%
311 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](\n,-0.25)(\N,0.25)}
312 \begin{psclip}{\pscircle[fillstyle=solid,fillcolor=white,linestyle=none]{3}}
313 \multido{\ry=-2.75+1,\rY=-2.25+1}{6}{
314 \multido{\n=-2.75+1.00,\N=-2.25+1.00}{6}{%
315 \psframe*[linecolor=red](\n,\ry)(\N,\rY)}
316 }
317 \multido{\ry=-3.25+1,\rY=-2.75+1}{7}{
318 \multido{\n=-3.25+1.00,\N=-2.75+1.00}{7}{%
319 \psframe*[linecolor=blue](\n,\ry)(\N,\rY)}
320 }
321 \pscircle[doubleline=true]{3}
322 \end{psclip}
323 \end{pspicture}
324 \end{center}
325 \begin{verbatim}
326 \multido{\ry=-2.75+1,\rY=-2.25+1}{6}{
327 \multido{\n=-2.75+1.00,\N=-2.25+1.00}{7}{%
328 \psframeA[fillstyle=solid,fillcolor=red,linecolor=red](\n,\ry)(\N,\rY)}
329 }
330 \multido{\ry=-3.25+1,\rY=-2.75+1}{3}{
331 \multido{\n=-3.25+1.00,\N=-2.75+1.00}{7}{%
332 \psframeA[fillstyle=solid,fillcolor=blue,linecolor=blue](\n,\ry)(\N,\rY)}
333 }
334 \end{verbatim}
335 \section{\textbackslash{}pspolygonA}
336 En réalité la macro \verb+pspolygonA+ n'a pas été écrite. En effet il suffit de servir de \verb+\pslineA+ et de boucler le chemin en revenant au point origine.
337 \begin{center}
338 \begin{pspicture}(-5,-5)(5,5)
339 \psset{type=conical,Rmirror=3}
340 \pspolygon[linecolor=red,linewidth=1mm](2.5;30)(2.5;90)(2.5;150)(2.5;210)(2.5;270)(2.5;330)
341 \pslineA[linecolor=red,linewidth=1mm](2.5;30)(2.5;90)(2.5;150)(2.5;210)(2.5;270)(2.5;330)(2.5;30)
342 \rput(1.25,1){\pspolygon[linecolor=blue,fillstyle=solid,linewidth=1mm,fillcolor={[rgb]{1 0.875 0.5}}](0.75;30)(0.75;90)(0.75;150)(0.75;210)(0.75;270)(0.75;330)}
343 \multido{\i=30+60,\I=1+1}{6}{%
344 \pnode(!\i\space cos 0.75 mul 1.25 add \i\space sin 0.75 mul 1 add){A\I}
345 }
346 \pslineA[linecolor=blue,fillstyle=solid,linewidth=1mm,fillcolor={[rgb]{1 0.875 0.5}}](A1)(A2)(A3)(A4)(A5)(A1)
347 \pscircle[doubleline=true]{3}
348 \psdot[dotstyle=x](0,0)
349 \end{pspicture}
350 \end{center}
351 \begin{verbatim}
352 \begin{pspicture}(-5,-5)(5,5)
353 \psset{type=conical,Rmirror=3}
354 \pspolygon[linecolor=red,linewidth=1mm](2.5;30)(2.5;90)(2.5;150)(2.5;210)(2.5;270)(2.5;330)
355 \pslineA[linecolor=red,linewidth=1mm](2.5;30)(2.5;90)(2.5;150)(2.5;210)(2.5;270)(2.5;330)(2.5;30)
356 \rput(1.25,1){\pspolygon[linecolor=blue,fillstyle=solid,linewidth=1mm,fillcolor={[rgb]{1 0.875 0.5}}](0.75;30)(0.75;90)(0.75;150)(0.75;210)(0.75;270)(0.75;330)}
357 \multido{\i=30+60,\I=1+1}{6}{%
358 \pnode(!\i\space cos 0.75 mul 1.25 add \i\space sin 0.75 mul 1 add){A\I}
359 }
360 \pslineA[linecolor=blue,fillstyle=solid,linewidth=1mm,fillcolor={[rgb]{1 0.875 0.5}}](A1)(A2)(A3)(A4)(A5)(A1)
361 \pscircle[doubleline=true]{3}
362 \psdot[dotstyle=x](0,0)
363 \end{pspicture}
364 \end{verbatim}
365 On remarquera que le \verb+\rput(1.25,1)+ doit être remplacé par un calcul adapté. La macro \verb+\rputA+ n'a pas été définie.
366 \end{document}

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.