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'image est verticale --------------------------------------------------
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 /Zp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
80 /a Xv Xp sub dup mul Yv dup mul add def
81 /b Xv Xp mul Xv dup mul sub Yv dup mul sub def
82 /c R neg Xv dup mul add Yv dup mul add def
83 /d b dup mul a c mul sub 0.5 exp def
84 /rho1 b neg d sub a div def
85 /rho2 b neg d add a div def
86 rho2 rho1 ge {/rho rho1 def}{/rho rho2 def} ifelse
87 % /alpha 2 1 rho div sub Zv mul Zv Zp add div def
88 /xi Xv dup Xp sub rho mul sub def
89 /yi Yv 1 rho sub mul def
90 /zi Zv dup Zp sub rho mul sub def
91 /alpha 2 zi mul Zv sub zi Zv sub div def
92 /k 2 Xv xi mul Yv yi mul add mul R div def
93 /xv k xi mul Xv sub def
94 /yv k yi mul Yv sub def
95 xv dup xi sub alpha mul sub
96 yv dup yi sub alpha mul sub
98 %% === L'anamorphose conique ---------------------------------------------------
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
102 /rP Xp dup mul Yp dup mul add 0.5 exp def
103 /k Rmirror Zs Zv sub mul Zs rP mul Zv Rmirror mul sub div def
106 k 0 eq {/Zi Zs def}{/Zi Zv 1 k sub mul def} ifelse
108 /THETA Rmirror Zs Atan def
109 /ALPHA 90 2 THETA mul sub BETA add def
110 /rI Xi dup mul Yi dup mul add 0.5 exp def
111 /KP' Zi ALPHA sin ALPHA cos div div def
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 %% === L'anamorphose spherique ---------------------------------------------------
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
121 /rV Xv dup mul Yv dup mul add Zv dup mul add def
122 /rP Xp dup mul Yp dup mul add def
123 /A rP rV add Xv Xp mul Yv Yp mul add 2 mul sub def
124 /B rP neg Xv Xp mul add Yv Yp mul add def
126 /Discriminant B dup mul A C mul sub 0.5 exp def
127 /solution1 B neg Discriminant add
129 /solution2 B neg Discriminant sub
131 solution1 0 gt {/Coeff1 solution1 def}{/Coeff1 solution2 def}
133 /Xi Xp 1 Coeff1 sub mul Coeff1 Xv mul add def
134 /Yi Yp 1 Coeff1 sub mul Coeff1 Yv mul add def
135 /Zi Coeff1 Zv mul def
136 /Coeff2 2 Xv Xi mul Yv Yi mul add Zv Zi mul add mul R div def % k+2
137 /Xv2 Coeff2 Xi mul Xv sub def
138 /Yv2 Coeff2 Yi mul Yv sub def
139 /Zv2 Coeff2 Zi mul Zv sub def
140 /Coeff3 Zi Zi Zv2 sub div def
141 /Ximage Xi Coeff3 Xv2 Xi sub mul add def
142 /Yimage Yi Coeff3 Yv2 Yi sub mul add def
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 %% === La perspective ---------------------------------------------------
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
149 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
151 Yp ua add xD add div % x'
152 ua yH xD add mul Yp yH mul add
153 Yp ua add xD add div % y'
155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156 %% === La perspective inversee --------------------------------------------------
157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 /pst-inverseperspective{
159 /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
162 ua yH xD add mul ua xD add Yp mul sub
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166 %% === Les commandes -----------------------------------------------------------
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171 t@@x t@@y translate s@@x s@@y scale