Debian Codegraph @

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

raw
1 % ubhtransients.mp
2 % L. Nobre G.
3 % 2003
4
5 numeric SingleContinuosParameter;
6 SingleContinuosParameter = 0.95;
7
8 numeric vertn, horin, grids, thex, they, varx, xcomp;
9 numeric ymax, xmax, i, j, size, u, ycomp, theta, phi;
10 numeric power, xlim, ylim, frax, fray, allang, shift;
11 numeric perang, ampper, velang, displamp, hdk;
12 numeric velfunc, auxfunc, homang, vpower;
13 pair actpos, direct, one, two, displvec;
14 path cirma;
15 color thedark;
16 path VGAborder;
17
18 u := 0.5mm;
19 size := 1.14u;
20 grids := 4u;
21 hdk := 0.47;
22
23 % This is for the sudden rotation
24 %allang := SingleContinuosParameter[0,80];
25 %homang := 0;
26
27 % This is for the UH evolution
28 % allang := 80;
29 % homang := SingleContinuosParameter[0,80];
30 % ampper := 0;
31 % displamp := 0;
32 % frax := 1.2;
33 % fray := 1.6;
34 % velang := 0;
35 % power := 1;
36 % vpower := 1;
37
38 % The next homang parameter when in UBH evolution
39 % has two parts:
40 % Part1 - SingleContinuosParameter from 0 to 1 [0,45]
41 % Part2 - SingleContinuosParameter from 1 to 0 [85,45]
42 % homang := SingleContinuosParameter[0,45];
43 % allang := 85;
44 % ampper := SingleContinuosParameter[0,33];
45 % velang := 15;
46 % displamp := SingleContinuosParameter[0,5u];
47 % frax := 1.2;
48 % fray := 2.0;
49 % power := 1;
50 % vpower := 1;
51
52 % This is for the UB evolution
53 allang := 90;
54 homang := 0;
55 ampper := SingleContinuosParameter[0,84];
56 displamp := SingleContinuosParameter[0,9u];
57 frax := 0.8;
58 fray := 1.5;
59 velang := 0;
60 power := 1;
61 vpower := 1;
62
63 %power := SingleContinuosParameter[1,0.47];
64 %vpower := 1.0/power;
65
66 xlim := 115.00;
67 ylim := 86.025;
68 vertn := 2.0*ylim/grids;
69 horin := 2.0*xlim/grids;
70 ymax := floor(0.5*(vertn*fray-1));
71 xmax := floor(0.5*(horin*frax-1));
72 %varx := 450/(0.5*(vertn-1));% in UH and UBH
73 varx := 350/(0.5*(vertn-1));% in UB
74
75 VGAborder := (-xlim,-ylim)-- %
76 ( xlim,-ylim)-- %
77 ( xlim, ylim)-- %
78 (-xlim, ylim)--cycle; %
79
80 def mypower( expr base, expo ) =
81 begingroup
82 save aux;
83 numeric aux;
84 if base=0:
85 aux = 1;
86 else:
87 aux = abs(base)/base;
88 fi;
89 ( aux*(abs(base)**expo) )
90 endgroup
91 enddef;
92
93 def produce_vga_border =
94 begingroup
95 draw VGAborder withcolor background withpen pencircle scaled 0;
96 clip currentpicture to VGAborder
97 endgroup
98 enddef;
99
100 beginfig(0);
101 pickup pencircle scaled u;
102 cirma := fullcircle scaled (1.43*grids);
103 for i=-xmax upto xmax:
104 for j=-ymax upto ymax:
105 actpos:=(grids*(i,j)) rotated (-allang);
106 thex:=i*varx;
107 they:=j*varx;
108 auxfunc:=dir(velang) dotprod (thex,they);
109 perang :=ampper*mypower(sind(auxfunc),power);
110 theta:=180-allang+perang+homang;
111 direct:=dir(theta);
112 velfunc:=-displamp*mypower(cosd(auxfunc),vpower);
113 displvec:=dir(velang)*velfunc;
114 actpos := actpos+displvec;
115 thedark := (1-hdk*(ypart direct))*white;
116 fill cirma shifted actpos withcolor thedark;
117 endfor;
118 endfor;
119 for i=-xmax upto xmax:
120 for j=-ymax upto ymax:
121 actpos:=(grids*(i,j)) rotated (-allang);
122 thex:=i*varx;
123 they:=j*varx;
124 auxfunc:=dir(velang) dotprod (thex,they);
125 perang :=ampper*mypower(sind(auxfunc),power);
126 theta:=180-allang+perang+homang;
127 direct:=dir(theta);
128 velfunc:=-displamp*mypower(cosd(auxfunc),vpower);
129 displvec:=dir(velang)*velfunc;
130 actpos := actpos+displvec;
131 one:=actpos-size*direct;
132 two:=actpos+size*direct;
133 draw one--two;
134 endfor;
135 endfor;
136 produce_vga_border;
137 endfig;
138
139 end;