Debian Codegraph @

texmf-dist/doc/metapost/featpost/example/experimental2Dsetup.mp

raw
1 % experimental2Dsetup.mp
2 % L. Nobre G.
3 % 2002
4
5 verbatimtex
6 \documentclass{article}
7 \usepackage{palatino}
8 \usepackage{concmath}
9 \usepackage{ccfonts}
10 \begin{document}
11 etex
12
13 beginfig(1);
14 % linecap := squared;
15
16 numeric salto, shif, rotang, cfac, posang;
17 numeric innerray, outerray, midleray, thebiray, otherray;
18 numeric midmidcir, midotharc, lblfac, wavecray, midwavarc;
19 path loricir, roricir, baserec, sampleh, wavecarc;
20 path innercirc, outercirc, midlecirc, otherarch;
21 path oridirh, oridirn, oridirp, oridirv, oridire;
22 path dirhoriz, dirnegat, dirposit, dirverti, direff;
23 path lowcut, higcut, glassre, wavecarch, field;
24 pair midmidcirpos, midotharcpos, midwavarcpos, mideffcirpos;
25 pen thickpen;
26 color samplecolor, magnetcolor, samplebordercolor;
27 picture lblpiplu, lblalpha, lblwavec, lblqu, lblno, lblfield;
28 numeric hei, wid, thi, pro, pol, mar;
29 path themagnet, effcirc, diry, oridiry;
30 numeric circleray, squareray, glasssize, effang, effraya, effrayb;
31 picture lblx, lbly, lbleff;
32 numeric mideffcir, yray;
33 pair lastoridire;
34
35 pickup pencircle scaled 0.15mm;
36 thickpen = pencircle scaled 1.7bp;
37
38 samplecolor = 0.88white;
39 magnetcolor = 0.37white;
40 samplebordercolor = 0.1white;
41 % samplecolor = (0.85,0.9,0.8);
42 % magnetcolor = (0.2,0.27,0.58);
43 % samplebordercolor = blue;
44 salto = 1mm;
45 rotang = 7;
46 posang = -28;
47 effang = -20;
48 shif = 50salto;
49 thi = 5salto;
50 pol = 25salto;
51 pro = 8salto;
52 wid = 58salto;
53 cfac = 0.5;
54 lblfac = 1.5;
55 innerray = 27salto;
56 circleray = 0.93innerray;
57 squareray = 0.93circleray;
58 glasssize = 0.42squareray;
59 outerray = 60salto;
60 midleray = 55salto;
61 yray = 53salto;
62 thebiray = 145salto;
63 otherray = 115salto;
64 wavecray = 0.5*(thebiray+otherray);
65 effraya = 0.45*(midleray+otherray);
66 effrayb = 0.56*(midleray+otherray);
67 innercirc = fullcircle scaled innerray;
68 outercirc = fullcircle scaled outerray;
69 midlecirc = (halfcircle cutbefore (origin--dir(90+posang)))
70 scaled midleray;
71 midmidcir = 0.5*length midlecirc;
72 midmidcirpos = point midmidcir of midlecirc;
73 effcirc = ((halfcircle cutbefore (origin--dir(90+effang)))
74 cutafter (origin--up))
75 scaled effraya;
76 mideffcir = 0.5*length effcirc;
77 mideffcirpos = point mideffcir of effcirc;
78 otherarch = ((halfcircle cutbefore (origin--dir(90+posang)))
79 cutafter (origin--up))
80 scaled otherray;
81 midotharc = 0.5*length otherarch;
82 midotharcpos = point midotharc of otherarch;
83 wavecarch = ((halfcircle cutafter (origin--dir(90+rotang)))
84 cutbefore (origin--up))
85 scaled wavecray;
86 midwavarc = 0.5*length wavecarch;
87 midwavarcpos = point midwavarc of wavecarch;
88 oridirh = origin--0.5*outerray*left;
89 oridirv = origin--0.5*thebiray*up;
90 oridirn = origin--0.5*thebiray*dir(90+rotang);
91 oridirp = origin--0.5*wavecray*dir(90+posang);
92 oridiry = origin--0.5*yray*dir(180+posang);
93 lastoridire = 0.5*effrayb*dir(90+effang);
94 oridire = origin--lastoridire;
95 dirhoriz = oridirh cutbefore innercirc;
96 dirverti = oridirv cutbefore innercirc;
97 dirnegat = oridirn cutbefore innercirc;
98 dirposit = oridirp cutbefore innercirc;
99 direff = oridire cutbefore innercirc;
100 diry = oridiry cutbefore innercirc;
101 field = (0.5innerray,0)--(0.5wid-salto,0);
102 loricir = halfcircle scaled circleray rotated 90;
103 roricir = halfcircle scaled circleray rotated 270;
104 baserec = (unitsquare shifted (-0.5*(1,1)))
105 xscaled 2
106 scaled squareray;
107 glassre = (unitsquare shifted (-0.5*(1,1)))
108 yscaled (13.0/6.0)
109 scaled glasssize;
110 lowcut = subpath (0,1) of baserec;
111 higcut = subpath (2,3) of baserec;
112 sampleh = buildcycle( higcut, loricir, reverse lowcut, roricir );
113 draw glassre rotated 90 dashed evenly withcolor (cfac*white);
114 % draw glassre rotated rotang dashed evenly withcolor (cfac*(white-blue));
115 fill glassre rotated posang withcolor samplecolor;
116 draw glassre rotated posang withcolor samplebordercolor;
117 draw sampleh rotated posang withpen thickpen withcolor blue;
118 drawarrow reverse midlecirc;
119 drawarrow reverse otherarch;
120 drawarrow wavecarch;
121 drawarrow reverse effcirc;
122 draw dirhoriz dashed evenly scaled 2;
123 draw dirverti dashed evenly scaled 2;
124 drawarrow dirnegat withpen thickpen;
125 drawarrow dirposit withpen thickpen;
126 drawarrow direff withpen thickpen;
127 drawarrow reverse field withpen thickpen;
128 drawarrow direff withpen thickpen;
129 drawarrow diry withpen thickpen;
130 lblpiplu = btex $\alpha = \frac{\pi}{2}+\beta$ etex scaled lblfac;
131 lblalpha = btex $\beta$ etex scaled lblfac;
132 lblwavec = btex $\Psi$ etex scaled lblfac;
133 lblqu = btex $\vec{q}\,$ etex scaled lblfac;
134 lblno = btex $\vec{n}_0$ etex scaled lblfac;
135 lblfield = btex $\vec{B}$ etex scaled lblfac;
136 lblx = btex $x$ etex scaled lblfac;
137 lbly = btex $y$ etex scaled lblfac;
138 lbleff = btex $\beta_{\mbox{\small eff}}$ etex scaled lblfac;
139 label.ulft( lblpiplu, midmidcirpos );
140 label.top( lblalpha, midotharcpos );
141 label.top( lblwavec, midwavarcpos );
142 label.llft( lblqu, point 0.7 of dirnegat );
143 label.lrt( lblx, point 0.7 of dirposit );
144 label.top( lblfield, point 0.5 of field );
145 label.llft( lbly, point 0.5 of diry );
146 label.top( lbleff, mideffcirpos );
147 label.top( lblno, lastoridire );
148 hei = pol+4thi;
149 mar = (hei-2*thi-pol)*0.5;
150 z100 = (pro,mar);
151 z0 = (wid,pol)*0.5;
152 z1 = z0 + z100;
153 z2 = z1 + (thi,0);
154 z3 = (xpart z2, pol*0.5+mar-hei);
155 z4 = (-xpart z2, ypart z3);
156 z5 = (-xpart z2, ypart z2);
157 z6 = (-xpart z1, ypart z1);
158 z7 = (-xpart z0, ypart z0);
159 z8 = (xpart z7, -pol*0.5);
160 z9 = z8 - z100;
161 z10 = z9 - (0,thi);
162 z11= (xpart z1, ypart z10);
163 z12= z11+ (0,thi);
164 z13= (xpart z0, -ypart z0);
165 themagnet = z0--z1--z2--z3--z4--z5--z6--z7--
166 z8--z9--z10--z11--z12--z13--cycle;
167 fill themagnet withcolor magnetcolor;
168 draw themagnet withpen thickpen;
169 endfig;
170
171 verbatimtex
172 \end{document}
173 etex
174
175 end;