Contents of file 'poincare/stoke.mp':
1 % This Filename: stoke.mp [MetaPost source]
2 % Creation time: Thu Jan 23 20:19:34 2014
3 %
4 % Copyright (C) 1997-2005, Fredrik Jonsson <fj@optics.kth.se>
5 %
6 % Input Filename [Stokes parameters]:
7 % This MetaPost source code was automatically generated by poincare
8 % Full set of command line options that generated this code:
9 % --verbose --normalize --axislengths 0.3 1.6 0.3
10 % 2.7 0.3 1.5 --axislabels S_1 bot
11 % S_2 bot S_3 rt --rotatephi 15.0
12 % --rotatepsi -70.0 --shading 0.75 0.99 --rhodivisor
13 % 50 --phidivisor 80 --scalefactor 25.0 --outputfile
14 % stoke.mp --auxsource polstate.mp
15 %
16 % Description: Map of Stokes parameters, visualized as trajectories
17 % onto the Poincare sphere. This file contains MetaPost
18 % source code, to be compiled with John Hobby's MetaPost
19 % compiler or used with anything that understands MetaPost
20 % source code.
21 %
22 % If you want to create PostScript output, or include the resulting
23 % output in a TeX document, this example illustrates the procedure,
24 % assuming 'poincaremap.mp' to be the name of the file containing the
25 % MetaPost code to be visualized: (commands run on command-line)
26 %
27 % mp poincaremap.mp;
28 % echo "\input epsf\centerline{\epsfbox{poincaremap.1}}\bye" > tmp.tex;
29 % tex tmp.tex;
30 % dvips tmp.dvi -o poincaremap.ps;
31 %
32 % Here, the first command compiles the MetaPost source code, and leaves
33 % an Encapsulated PostScript file named 'poincaremap.1', containing TeX
34 % control codes for characters, etc. This file does not contain any
35 % definitions for characters or TeX-specific items, and it cannot be
36 % viewed or printed simply as is stands; it must rather be included into
37 % TeX code in order to provide something useful.
38 % The second command creates a temporary minimal TeX-file 'tmp.tex',
39 % that only includes the previously generated Encapsulated PostScript
40 % code.
41 % The third command compiles the TeX-code into device-independent,
42 % or DVI, output, stored in the file 'tmp.dvi'.
43 % Finally, the last command converts the DVI output into a free-
44 % standing PostScript file 'poincaremap.ps', to be printed or viewed
45 % with some PostScript viewer, such as GhostView.
46 %
47 scalefactor := 25.000000 mm;
48 rot_psi := -70.000000; % Rotation angle round z-axis (first rotation)
49 rot_phi := 15.000000; % Rotation angle round y-axis (second rotation)
50 alpha := -35.416613; % == arctan(sin(rot_phi)*tan(rot_psi))
51 beta := -5.381520; % == arctan(sin(rot_phi)/tan(rot_psi))
52
53 %
54 % Parameters specifying the location of the light source; for Phong
55 % shading of the sphere.
56 %
57 % phi_source: Angle (in deg.) to light source counterclockwise
58 % 'from three o'clock', viewed from the observer.
59 %
60 % theta_source: Angle (in deg.) between light source and observer,
61 % seen from the centre of the sphere.
62 %
63 % Parameters specifying the shading 'intensity' in terms of maximum
64 % (for the highlighs) and minimum (for the deep shadowed regions)
65 % values for the Phong shading. '0.0' <=> 'black'; '1.0' <=> 'white'
66 %
67 % upper_value: Maximum value of whiteness.
68 % lower_value: Minimum value of whiteness.
69 %
70 phi_source := 30.000000;
71 theta_source := 30.000000;
72 upper_value := 0.990000;
73 lower_value := 0.750000;
74 radius := scalefactor;
75 delta_rho := radius/50.000000;
76 delta_phi := 360.0/80.000000;
77 beginfig(1);
78 path p;
79 path equator;
80 transform T;
81 c1:=lower_value;
82 c2:=upper_value-lower_value;
83 nx_source := sind(theta_source)*cosd(phi_source);
84 ny_source := sind(theta_source)*sind(phi_source);
85 nz_source := cosd(theta_source);
86 phistop := 360.0;
87 rhostop := radius - delta_rho/2.0;
88 %
89 % Draw the shaded Poincare sphere projected on 2D screen coordinates
90 %
91 for rho=0.0cm step delta_rho until rhostop:
92 for phi=0.0 step delta_phi until phistop:
93 rhomid := rho + delta_rho/2.0;
94 phimid := phi + delta_phi/2.0;
95 x1 := rho*cosd(phi);
96 y1 := rho*sind(phi);
97 x2 := (rho+delta_rho)*cosd(phi);
98 y2 := (rho+delta_rho)*sind(phi);
99 x3 := (rho+delta_rho)*cosd(phi+delta_phi);
100 y3 := (rho+delta_rho)*sind(phi+delta_phi);
101 x4 := rho*cosd(phi+delta_phi);
102 y4 := rho*sind(phi+delta_phi);
103 p:=makepath makepen ((x1,y1)--(x2,y2)--(x3,y3)--(x4,y4)--(x1,y1));
104 quot := (rhomid/radius);
105 nx_object := quot*cosd(phimid);
106 ny_object := quot*sind(phimid);
107 nz_object := sqrt(1-quot*quot);
108 prod:=nx_object*nx_source+ny_object*ny_source
109 +nz_object*nz_source;
110 if prod < 0.0:
111 value := c1;
112 else:
113 value := c1 + c2*prod*prod;
114 fi
115 fill p withcolor value[black,white];
116 endfor
117 endfor
118
119 %
120 % Draw the 'equators' of the Poincare sphere
121 %
122 equator := halfcircle scaled (2.0*radius);
123 eqcolval := .45; % '0.0' <=> 'white'; '1.0' <=> 'black'
124
125 pickup pencircle scaled 0.600000 pt;
126 %
127 % Draw equator $S_3=0$...
128 %
129 T := identity yscaled sind(rot_phi) rotated 180.0;
130 draw equator transformed T withcolor eqcolval [white,black];
131
132 %
133 % ... then equator $S_2=0$...
134 %
135 T := identity yscaled (cosd(rot_phi)*sind(rot_psi))
136 rotated (270.0 + alpha);
137 draw equator transformed T withcolor eqcolval [white,black];
138
139 %
140 % ... and finally equator $S_1=0$.
141 %
142 T := identity yscaled (cosd(rot_phi)*cosd(rot_psi))
143 rotated (270.0 - beta);
144 draw equator transformed T withcolor eqcolval [white,black];
145
146 %
147 % Draw the $S_1$-, $S_2$- and $S_3$-axis of the Poincare sphere.
148 % First of all, calculate the transformations of the intersections
149 % for the unity sphere.
150 %
151 % Used variables:
152 %
153 % behind_distance : Specifies the relative distance of the coordi-
154 % axes to be plotted behind origo (in negative di-
155 % rection of respective axis.
156 %
157 % outside_distance_s1 : The relative distance from origo to the point
158 % of the arrow head of the coordinate axis S1.
159 % If this is set to 1.0, the arrow head will
160 % point directly at the Poincare sphere.
161 %
162 % outside_distance_s2 : Same as above, except that this one controls
163 % the S2 coordinate axis instead.
164 %
165 % outside_distance_s3 : Same as above, except that this one controls
166 % the S3 coordinate axis instead.
167 %
168 % insidecolval : Specifies the shade of gray to use for the parts
169 % of the coordinate axes that are inside the Poin-
170 % care sphere. Values must be between 0 and 1,
171 % where: '0.0' <=> 'white'; '1.0' <=> 'black'
172 %
173 behind_distance_s1 := -0.300000;
174 behind_distance_s2 := -0.300000;
175 behind_distance_s3 := -0.300000;
176 outside_distance_s1 := 1.600000;
177 outside_distance_s2 := 2.700000;
178 outside_distance_s3 := 1.500000;
179 insidecolval := .85; % '0.0' <=> 'white'; '1.0' <=> 'black'
180
181 pickup pencircle scaled 0.600000 pt;
182 %
183 % Start with drawing the x-axis...
184 %
185 x_bis_start := radius*behind_distance_s1*cosd(rot_psi)*cosd(rot_phi);
186 y_bis_start := radius*behind_distance_s1*sind(rot_psi);
187 z_bis_start := -radius*behind_distance_s1*cosd(rot_psi)*sind(rot_phi);
188 x_bis_intersect := radius*cosd(rot_psi)*cosd(rot_phi);
189 y_bis_intersect := radius*sind(rot_psi);
190 z_bis_intersect := -radius*cosd(rot_psi)*sind(rot_phi);
191 p := makepath makepen (y_bis_intersect,z_bis_intersect)--
192 (outside_distance_s1*y_bis_intersect,
193 outside_distance_s1*z_bis_intersect);
194 drawarrow p;
195 label.bot(btex $S_1$ etex,
196 (outside_distance_s1*y_bis_intersect,
197 outside_distance_s1*z_bis_intersect));
198
199 %
200 % ... then draw the y-axis ...
201 %
202 x_bis_start := -radius*behind_distance_s2*sind(rot_psi)*cosd(rot_phi);
203 y_bis_start := radius*behind_distance_s2*cosd(rot_psi);
204 z_bis_start := radius*behind_distance_s2*sind(rot_psi)*sind(rot_phi);
205 x_bis_intersect := -radius*sind(rot_psi)*cosd(rot_phi);
206 y_bis_intersect := radius*cosd(rot_psi);
207 z_bis_intersect := radius*sind(rot_psi)*sind(rot_phi);
208 p := makepath makepen (y_bis_intersect,z_bis_intersect)--
209 (outside_distance_s2*y_bis_intersect,
210 outside_distance_s2*z_bis_intersect);
211 drawarrow p;
212 label.bot(btex $S_2$ etex,
213 (outside_distance_s2*y_bis_intersect,
214 outside_distance_s2*z_bis_intersect));
215
216 %
217 % ... then, finally, draw the z-axis.
218 %
219 x_bis_start := radius*behind_distance_s3*sind(rot_phi);
220 y_bis_start := 0.0;
221 z_bis_start := radius*behind_distance_s3*cosd(rot_phi);
222 x_bis_intersect := radius*sind(rot_phi);
223 y_bis_intersect := 0.0;
224 z_bis_intersect := radius*cosd(rot_phi);
225 p := makepath makepen (y_bis_intersect,z_bis_intersect)--
226 (outside_distance_s3*y_bis_intersect,
227 outside_distance_s3*z_bis_intersect);
228 drawarrow p;
229 label.rt(btex $S_3$ etex,
230 (outside_distance_s3*y_bis_intersect,
231 outside_distance_s3*z_bis_intersect));
232
233 %
234 % The following external file is included (using the --auxsource option): polstate.mp [MetaPost source]
235 %
236 input polstate.mp
237 endfig;
238 end
239
Generated by ::viewsrc::