| 1 |
% integerbars.mp |
| 2 |
% L. Nobre G. |
| 3 |
% 2006 |
| 4 |
|
| 5 |
input featpost3Dplus2D; |
| 6 |
|
| 7 |
prologues := 1; |
| 8 |
|
| 9 |
def randcolor = |
| 10 |
(0.1+uniformdeviate(0.8),0.1+uniformdeviate(0.8),0.1+uniformdeviate(0.8)) |
| 11 |
enddef; |
| 12 |
|
| 13 |
beginfig(1); |
| 14 |
numeric u, ltl, ltr, lsl, lsr, lbmin, lbmax, lbtop, i, j, k, a; |
| 15 |
numeric hist[], hclass, aaux, r; |
| 16 |
color pickc; |
| 17 |
pair tcross; |
| 18 |
pickup pencircle scaled 1.5pt; |
| 19 |
u = 5mm; |
| 20 |
r = 5mm; |
| 21 |
ltl = 9; |
| 22 |
ltr = 9; |
| 23 |
lsl = 4; |
| 24 |
lsr = 1; |
| 25 |
lbmin = 4; |
| 26 |
lbtop = 7; |
| 27 |
lbmax = ltl+ltr-1; |
| 28 |
hclass = 2; |
| 29 |
if lbtop > lbmax: lbtop := lbmax; fi; |
| 30 |
draw origin; |
| 31 |
for a=0 step hclass until 180-hclass: |
| 32 |
hist[a] = 0; |
| 33 |
endfor; |
| 34 |
for i=lbmin upto lbtop: |
| 35 |
pickc := randcolor; |
| 36 |
drawoptions( withcolor pickc ); |
| 37 |
draw (i*u,0); |
| 38 |
for j=lsl upto ltl: |
| 39 |
for k=lsr upto ltr: |
| 40 |
if (j+k > i) and (j < i+k) and (k < i+j): |
| 41 |
tcross := radialcross( origin, j*u, (i*u,0), k*u, true ); |
| 42 |
draw tcross; |
| 43 |
aaux := angle( tcross ); |
| 44 |
a := 0; |
| 45 |
forever: |
| 46 |
a := a + hclass; |
| 47 |
exitif aaux < a; |
| 48 |
endfor; |
| 49 |
hist[a] := incr( hist[a] ); |
| 50 |
fi; |
| 51 |
endfor; |
| 52 |
endfor; |
| 53 |
endfor; |
| 54 |
fill origin-- for a=hclass step hclass until 180-hclass: |
| 55 |
(r*dir(a)*hist[a-hclass])--(r*dir(a)*hist[a])-- endfor cycle; |
| 56 |
endfig; |
| 57 |
|
| 58 |
end. |