summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/mpfields.mp
blob: 6b877da5b1c8f69a106be910d5e1b0dfaef2df9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
%input mp-tool;

def projectyz( expr theta, phi ) = 
	(cosd(theta)*sind(phi),sind(theta))
enddef;

numeric vertn, horin, grids, thex, they, varc, xcomp;
numeric ymax, xmax, i, j, size, u, ycomp, theta, phi;
numeric power;
pair actpos, direct, one, two;

u := 0.5mm;
power := 0.8;
vertn := 20;
horin := 41;
size := 3u; 
grids := 8u;
ymax := 0.5*(vertn-1);
xmax := 0.5*(horin-1);
varc := 90/ymax;

beginfig(0);				% splay
	pickup pencircle scaled u;
	for i=-xmax upto xmax:	
	    for j=-ymax upto ymax:
		actpos:=grids*(i,j);
		thex:=i*varc;
		they:=j*varc;
		theta:=90*(cosd(they)**power);
		phi:=0;
		direct:=projectyz(theta,phi);
		one:=actpos-size*direct;
		two:=actpos+size*direct;
		draw one--two;
	    endfor; 
	endfor;
endfig;

beginfig(2);				% bend
	pickup pencircle scaled u;
	for i=-xmax upto xmax:	
	    for j=-ymax upto ymax:
		actpos:=grids*(i,j);
		thex:=i*varc;
		they:=j*varc;
		theta:=90*((1-cosd(they))**(1/power));
		phi:=0;
		direct:=projectyz(theta,phi);
		one:=actpos-size*direct;
		two:=actpos+size*direct;
		draw one--two;
	    endfor; 
	endfor;
endfig;

beginfig(4);				% twist
	pickup pencircle scaled u;
	for i=-xmax upto xmax:	
	    for j=-ymax upto ymax:
		actpos:=grids*(i,j);
		thex:=i*varc;
		they:=j*varc;
		theta:=0;
		phi:=90*(cosd(they)**power);
		direct:=projectyz(theta,phi);
		one:=actpos-size*direct;
		two:=actpos+size*direct;
		draw one--two;
	    endfor; 
	endfor;
endfig;

beginfig(3);				% splaytwist in splay
	pickup pencircle scaled u;
	for i=-xmax upto xmax:	
	    for j=-ymax upto ymax:
		actpos:=grids*(i,j);
		thex:=i*varc;
		they:=j*varc;
		theta:=90*cosd(they)*cosd(thex);
		phi:=60*sind(2*they)*sind(thex);
		direct:=projectyz(theta,phi);
		one:=actpos-size*direct;
		two:=actpos+size*direct;
		draw one--two;
	    endfor; 
	endfor;
endfig;

beginfig(5);				% splaytwist in twist
	pickup pencircle scaled u;
	for i=-xmax upto xmax:	
	    for j=-ymax upto ymax:
		actpos:=grids*(i,j);
		thex:=i*varc;
		they:=j*varc;
		theta:=30*sind(2*they)*sind(thex);
		phi:=-90*cosd(they)*cosd(thex);
		direct:=projectyz(theta,phi);
		one:=actpos-size*direct;
		two:=actpos+size*direct;
		draw one--two;
	    endfor; 
	endfor;
endfig;

beginfig(7);				% splaytwist in bend
	pickup pencircle scaled u;
	for i=-xmax upto xmax:	
	    for j=-ymax upto ymax:
		actpos:=grids*(i,j);
		thex:=i*varc;
		they:=j*varc;
		theta:=90*cosd(they)*sind(thex);
		phi:=30*sind(2*they)*cosd(thex);
		direct:=(cosd(theta)*sind(phi),cosd(theta)*cosd(phi));
		one:=actpos-size*direct;
		two:=actpos+size*direct;
		draw one--two;
	    endfor; 
	endfor;
endfig;

beginfig(1);				% splay-bend wall
	pickup pencircle scaled u;
	for i=-xmax upto xmax:	
	    for j=-ymax upto ymax:
		actpos:=grids*(i,j);
		thex:=i*varc;
		they:=j*varc;
		theta:=0;
		phi:=2*angle(1,mexp(thex*9));
		direct:=(cosd(theta)*sind(phi),cosd(theta)*cosd(phi));
		one:=actpos-size*direct;
		two:=actpos+size*direct;
		draw one--two;
	    endfor; 
	endfor;
endfig;

prologues := 1;

beginfig(6);
  pickup pencircle scaled u;
  numeric rescal;
  rescal = 0.15;
  for i=-xmax upto xmax:	
    for j=-ymax upto ymax:
      actpos:=grids*(i,j);
      thex:=i*rescal;
      they:=j*rescal;
      direct:=unitvector((1,they-thex));
      one:=actpos-size*direct;
      two:=actpos+size*direct;
      draw one--two;
    endfor; 
  endfor;
endfig;

end;