3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %% === Capture de commandes de systemdict --------------------------------------
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 /LINETO { systemdict /lineto get exec } def
7 /MOVETO { systemdict /moveto get exec } def
8 /CURVETO { systemdict /curveto get exec } def
9 /CLOSEPATH { systemdict /closepath get exec } def
10 /RLINETO { systemdict /rlineto get exec } def
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 %% === Transformation des commandes de construction des path(s) ----------------
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %% 12/10/2011 : version incomplète et un peu brute !
15 /tx@anamorphosisPathDict 50 dict def tx@anamorphosisPathDict begin
17 /s@y ED /s@x ED /c@x s@x def /c@y s@y def
18 s@x s@y Anamorphose MOVETO
21 /c@yt ED /c@xt ED /dx c@xt c@x sub 50 div def /dy c@yt c@y sub 50 div def
22 1 1 50 {dup dx mul c@x add exch dy mul c@y add Anamorphose LINETO} for
23 /c@x c@xt def /c@y c@yt def
26 s@x s@y lineto CLOSEPATH
33 20 div /s ED 1 s sub /t ED
34 t c@x mul 3 s c@xa mul mul add t mul 3 s s c@xb mul mul mul add t mul s 3 exp c@xt mul add
35 t c@y mul 3 s c@ya mul mul add t mul 3 s s c@yb mul mul mul add t mul s 3 exp c@yt mul add
38 /c@x c@xt def /c@y c@yt def
45 20 div /s ED 1 s sub /t ED
46 t c@x mul 3 s c@xa mul mul add t mul 3 s s c@xb mul mul mul add t mul s 3 exp c@xt mul add
47 t c@y mul 3 s c@ya mul mul add t mul 3 s s c@yb mul mul mul add t mul s 3 exp c@yt mul add
50 /c@x c@xt def /c@y c@yt def
53 c@y add exch c@x add exch lineto
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %% === L'anamorphose cylindrique -----------------------------------------------
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
61 /a Xv Xp sub dup mul Yv Yp sub dup mul add def
62 /b Xv Xp mul Yv Yp mul add Xv dup mul sub Yv dup mul sub def
63 /c R neg Xv dup mul add Yv dup mul add def
64 /d b dup mul a c mul sub 0.5 exp def
65 /rho b neg d sub a div def
66 /alpha 2 1 rho div sub def
67 /xi Xv dup Xp sub rho mul sub def
68 /yi Yv dup Yp sub rho mul sub def
69 /k 2 Xv xi mul Yv yi mul add mul R div def
70 /xv k xi mul Xv sub def
71 /yv k yi mul Yv sub def
72 xv dup xi sub alpha mul sub
73 yv dup yi sub alpha mul sub
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 %% === L'anamorphose conique ---------------------------------------------------
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
80 /rP Xp dup mul Yp dup mul add 0.5 exp def
81 /k Rmirror Zs Zv sub mul Zs rP mul Zv Rmirror mul sub div def
84 k 0 eq {/Zi Zs def}{/Zi Zv 1 k sub mul def} ifelse
86 /THETA Rmirror Zs Atan def
87 /ALPHA 90 2 THETA mul sub BETA add def
88 /rI Xi dup mul Yi dup mul add 0.5 exp def
89 /KP' Zi ALPHA sin ALPHA cos div div def
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 %% === L'anamorphose spherique ---------------------------------------------------
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
99 /rV Xv dup mul Yv dup mul add Zv dup mul add def
100 /rP Xp dup mul Yp dup mul add def
101 /A rP rV add Xv Xp mul Yv Yp mul add 2 mul sub def
102 /B rP neg Xv Xp mul add Yv Yp mul add def
104 /Discriminant B dup mul A C mul sub 0.5 exp def
105 /solution1 B neg Discriminant add
107 /solution2 B neg Discriminant sub
109 solution1 0 gt {/Coeff1 solution1 def}{/Coeff1 solution2 def}
111 /Xi Xp 1 Coeff1 sub mul Coeff1 Xv mul add def
112 /Yi Yp 1 Coeff1 sub mul Coeff1 Yv mul add def
113 /Zi Coeff1 Zv mul def
114 /Coeff2 2 Xv Xi mul Yv Yi mul add Zv Zi mul add mul R div def % k+2
115 /Xv2 Coeff2 Xi mul Xv sub def
116 /Yv2 Coeff2 Yi mul Yv sub def
117 /Zv2 Coeff2 Zi mul Zv sub def
118 /Coeff3 Zi Zi Zv2 sub div def
119 /Ximage Xi Coeff3 Xv2 Xi sub mul add def
120 /Yimage Yi Coeff3 Yv2 Yi sub mul add def
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 %% === La perspective ---------------------------------------------------
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
129 Yp ua add xD add div % x'
130 ua yH xD add mul Yp yH mul add
131 Yp ua add xD add div % y'
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 %% === La perspective inversee --------------------------------------------------
135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 /pst-inverseperspective{
137 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
140 ua yH xD add mul ua xD add Yp mul sub
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144 %% === Les commandes -----------------------------------------------------------
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
149 t@@x t@@y translate s@@x s@@y scale