Debian Codegraph @

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

raw
1 % srinathpolineni.mp
2 % L. Nobre G.
3 % 2013
4
5 input featpost3Dplus2D;
6
7 numeric thickn;
8 thickn = 7;
9
10 beginfig(8);
11 f := 3*(5,3,4);
12 Spread := 60;
13
14 numeric hstep, hmax, hsdev, basestep, basemax, basesdev;
15 numeric i, j, k, angsdev, cylength, cyradius, basen, hn;
16 numeric vcx, vcy, vcz, hcurr, xcurr, ycurr, hbase, aone;
17 numeric atwo, zcurr, counter, aonebase, atwobase;
18 color lenvec, currpos;
19
20 cylength := 0.6;
21 cyradius := 0.1;
22 basen := 12;
23 hn := 4;
24 basestep := cyradius*3.1;
25 hstep := cylength*1.5;
26 basesdev := cyradius*0.1;
27 hsdev := hstep*0.2;
28 hbase := -0.8;
29 angsdev := 7;
30 aonebase := 170;
31 atwobase := 12;
32
33 basemax := basen*basestep;
34 hmax := hn*hstep;
35 counter := 0;
36 for i=1 upto basen:
37 for j=1 upto basen:
38 hcurr := hbase;
39 forever:
40 exitunless hcurr < hmax+hbase;
41 hcurr := hcurr + hstep;
42 zcurr := hcurr + hsdev*normaldeviate;
43 xcurr := i*basestep + basesdev*normaldeviate;
44 ycurr := j*basestep + basesdev*normaldeviate;
45 aone := uniformdeviate( 360 );
46 atwo := angsdev*normaldeviate;
47 vcz := cosd( atwo );
48 vcy := sind( atwo )*sind( aone );
49 vcx := sind( atwo )*cosd( aone );
50 currpos := ( xcurr, ycurr, zcurr );
51 lenvec := cylength*( vcx, vcy, vcz );
52 counter := incr( counter );
53 generatedirline( counter, aone, 90-atwo, cylength, currpos );
54 endfor;
55 endfor;
56 endfor;
57 NL := counter;
58 director_invisible( true, thickn, false );
59 endfig;
60
61 beginfig(5);
62 counter := 0;
63 for i=1 upto basen:
64 for j=1 upto basen:
65 for hcurr=hbase step hstep until hmax:
66 zcurr := hcurr;
67 xcurr := i*basestep;
68 ycurr := j*basestep;
69 aone := aonebase;
70 atwo := atwobase;
71 vcz := cosd( atwo );
72 vcy := sind( atwo )*sind( aone );
73 vcx := sind( atwo )*cosd( aone );
74 currpos := ( xcurr, ycurr, zcurr );
75 lenvec := cylength*( vcx, vcy, vcz );
76 counter := incr( counter );
77 generatedirline( counter, aone, 90-atwo, cylength, currpos );
78 endfor;
79 endfor;
80 endfor;
81 NL := counter;
82 director_invisible( true, thickn, false );
83 endfig;
84
85 beginfig(6);
86 counter := 0;
87 for i=1 upto basen:
88 for j=1 upto basen:
89 for hcurr=hbase step hstep until hmax:
90 zcurr := hcurr + basesdev*normaldeviate;
91 xcurr := i*basestep + basesdev*normaldeviate;
92 ycurr := j*basestep + basesdev*normaldeviate;
93 aone := aonebase + angsdev*(normaldeviate-0.5);
94 atwo := atwobase + angsdev*(normaldeviate-0.5);
95 vcz := cosd( atwo );
96 vcy := sind( atwo )*sind( aone );
97 vcx := sind( atwo )*cosd( aone );
98 currpos := ( xcurr, ycurr, zcurr );
99 lenvec := cylength*( vcx, vcy, vcz );
100 counter := incr( counter );
101 generatedirline( counter, aone, 90-atwo, cylength, currpos );
102 endfor;
103 endfor;
104 endfor;
105 NL := counter;
106 director_invisible( true, thickn, false );
107 endfig;
108
109 beginfig(7);
110 counter := 0;
111 for i=1 upto basen:
112 for j=1 upto basen:
113 for hcurr=hbase step hstep until hmax:
114 zcurr := hcurr + basesdev*normaldeviate;
115 xcurr := i*basestep + basesdev*normaldeviate;
116 ycurr := j*basestep + basesdev*normaldeviate;
117 aone := aonebase + angsdev*(normaldeviate-0.5);
118 atwo := angsdev*(normaldeviate-0.5);
119 vcz := cosd( atwo );
120 vcy := sind( atwo )*sind( aone );
121 vcx := sind( atwo )*cosd( aone );
122 currpos := ( xcurr, ycurr, zcurr );
123 lenvec := cylength*( vcx, vcy, vcz );
124 counter := incr( counter );
125 generatedirline( counter, aone, 90-atwo, cylength, currpos );
126 endfor;
127 endfor;
128 endfor;
129 NL := counter;
130 director_invisible( true, thickn, false );
131 endfig;
132
133 beginfig(9);
134 counter := 0;
135 for i=1 upto basen:
136 for j=1 upto basen:
137 for hcurr=hbase step hstep until hmax:
138 zcurr := hbase + uniformdeviate(hmax-hbase);
139 xcurr := uniformdeviate(basen*basestep);
140 ycurr := uniformdeviate(basen*basestep);
141 aone := uniformdeviate(180);
142 atwo := uniformdeviate(180)-90;
143 vcz := cosd( atwo );
144 vcy := sind( atwo )*sind( aone );
145 vcx := sind( atwo )*cosd( aone );
146 currpos := ( xcurr, ycurr, zcurr );
147 lenvec := cylength*( vcx, vcy, vcz );
148 counter := incr( counter );
149 generatedirline( counter, aone, 90-atwo, cylength, currpos );
150 endfor;
151 endfor;
152 endfor;
153 NL := counter;
154 director_invisible( true, thickn, false );
155 endfig;
156
157 beginfig(1);
158 counter := 0;
159 for i=1 upto basen:
160 for j=1 upto basen:
161 zcurr := basesdev*normaldeviate;
162 xcurr := uniformdeviate(basen*basestep);
163 ycurr := uniformdeviate(basen*basestep);
164 aone := uniformdeviate(180);
165 atwo := 90;
166 vcz := cosd( atwo );
167 vcy := sind( atwo )*sind( aone );
168 vcx := sind( atwo )*cosd( aone );
169 currpos := ( xcurr, ycurr, zcurr );
170 lenvec := cylength*( vcx, vcy, vcz );
171 counter := incr( counter );
172 generatedirline( counter, aone, 90-atwo, cylength, currpos );
173 endfor;
174 endfor;
175 NL := counter;
176 director_invisible( true, thickn, false );
177 endfig;
178
179 beginfig(3);
180 counter := 0;
181 for i=1 upto basen:
182 for j=1 upto basen:
183 zcurr := basesdev*normaldeviate;
184 xcurr := uniformdeviate(basen*basestep);
185 ycurr := uniformdeviate(basen*basestep);
186 aone := uniformdeviate(180);
187 atwo := 0;
188 vcz := cosd( atwo );
189 vcy := sind( atwo )*sind( aone );
190 vcx := sind( atwo )*cosd( aone );
191 currpos := ( xcurr, ycurr, zcurr );
192 lenvec := cylength*( vcx, vcy, vcz );
193 counter := incr( counter );
194 generatedirline( counter, aone, 90-atwo, cylength, currpos );
195 endfor;
196 endfor;
197 NL := counter;
198 director_invisible( true, thickn, false );
199 endfig;
200
201 beginfig(2);
202 counter := 0;
203 for i=1 upto basen:
204 for j=1 upto basen:
205 zcurr := basesdev*normaldeviate;
206 xcurr := uniformdeviate(basen*basestep);
207 ycurr := uniformdeviate(basen*basestep);
208 aone := uniformdeviate(180);
209 atwo := angsdev*normaldeviate;
210 vcz := cosd( atwo );
211 vcy := sind( atwo )*sind( aone );
212 vcx := sind( atwo )*cosd( aone );
213 currpos := ( xcurr, ycurr, zcurr );
214 lenvec := cylength*( vcx, vcy, vcz );
215 counter := incr( counter );
216 generatedirline( counter, aone, 90-atwo, cylength, currpos );
217 endfor;
218 endfor;
219 NL := counter;
220 director_invisible( true, thickn, false );
221 endfig;
222
223 end;