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
|
% integerbars.mp
% L. Nobre G.
% 2006
input featpost3Dplus2D;
prologues := 1;
def randcolor =
(0.1+uniformdeviate(0.8),0.1+uniformdeviate(0.8),0.1+uniformdeviate(0.8))
enddef;
beginfig(1);
numeric u, ltl, ltr, lsl, lsr, lbmin, lbmax, lbtop, i, j, k, a;
numeric hist[], hclass, aaux, r;
color pickc;
pair tcross;
pickup pencircle scaled 1.5pt;
u = 5mm;
r = 5mm;
ltl = 9;
ltr = 9;
lsl = 4;
lsr = 1;
lbmin = 4;
lbtop = 7;
lbmax = ltl+ltr-1;
hclass = 2;
if lbtop > lbmax: lbtop := lbmax; fi;
draw origin;
for a=0 step hclass until 180-hclass:
hist[a] = 0;
endfor;
for i=lbmin upto lbtop:
pickc := randcolor;
drawoptions( withcolor pickc );
draw (i*u,0);
for j=lsl upto ltl:
for k=lsr upto ltr:
if (j+k > i) and (j < i+k) and (k < i+j):
tcross := radialcross( origin, j*u, (i*u,0), k*u, true );
draw tcross;
aaux := angle( tcross );
a := 0;
forever:
a := a + hclass;
exitif aaux < a;
endfor;
hist[a] := incr( hist[a] );
fi;
endfor;
endfor;
endfor;
fill origin-- for a=hclass step hclass until 180-hclass:
(r*dir(a)*hist[a-hclass])--(r*dir(a)*hist[a])-- endfor cycle;
endfig;
end.
|