| 1 |
% tuftescatter.mp |
| 2 |
% L. Nobre G. |
| 3 |
% IYP (2005) |
| 4 |
|
| 5 |
input featpost3Dplus2D; |
| 6 |
|
| 7 |
def linscatter = uniformdeviate( 2 ) - 1 enddef; |
| 8 |
|
| 9 |
def fullcalculator = |
| 10 |
begingroup |
| 11 |
color aux; |
| 12 |
numeric cx, cy; |
| 13 |
forever: |
| 14 |
cx := linscatter; |
| 15 |
cy := linscatter; |
| 16 |
exitif cx ++ cy < 0.8; % Saddle ray |
| 17 |
endfor; |
| 18 |
aux = ( cx, cy, cx*cx-cy*cy ); |
| 19 |
( eulerrotation( -25, -15, -5, aux ) ) % Rotation angles |
| 20 |
endgroup |
| 21 |
enddef; |
| 22 |
|
| 23 |
beginfig(1); |
| 24 |
numeric totalnum, classnum, sparksiz, pointray; |
| 25 |
totalnum = 250; % Number of data points |
| 26 |
classnum = 30; % Number of sparkline classes |
| 27 |
sparksiz = 0.34; % Maximum sparkline height |
| 28 |
pointray = 0.035; % Size of the data points |
| 29 |
f := ( 7, 6, 5 ); |
| 30 |
Spread := 120; |
| 31 |
numeric i, j, k, l, hx[], hy[], hz[], classtep; |
| 32 |
classtep = 2/classnum; |
| 33 |
color tmp; |
| 34 |
for j=0 upto classnum: |
| 35 |
hx[j] = 0; |
| 36 |
hy[j] = 0; |
| 37 |
hz[j] = 0; |
| 38 |
endfor; |
| 39 |
for l=1 upto totalnum: |
| 40 |
tmp := fullcalculator; |
| 41 |
for k=1 upto classnum: |
| 42 |
if ( X(tmp) <= k*classtep-1 ) and ( X(tmp) > (k-1)*classtep-1 ): |
| 43 |
hx[k] := incr( hx[k] ); |
| 44 |
fi; |
| 45 |
if ( Y(tmp) <= k*classtep-1 ) and ( Y(tmp) > (k-1)*classtep-1 ): |
| 46 |
hy[k] := incr( hy[k] ); |
| 47 |
fi; |
| 48 |
if ( Z(tmp) <= k*classtep-1 ) and ( Z(tmp) > (k-1)*classtep-1 ): |
| 49 |
hz[k] := incr( hz[k] ); |
| 50 |
fi; |
| 51 |
endfor; |
| 52 |
draw rigorouscircle( (-1,Y(tmp),Z(tmp)), red, pointray ); |
| 53 |
draw rigorouscircle( (X(tmp),-1,Z(tmp)), green, pointray ); |
| 54 |
draw rigorouscircle( (X(tmp),Y(tmp),-1), blue, pointray ); |
| 55 |
getready("fill rigorousfearpath(" |
| 56 |
& cstr( tmp ) |
| 57 |
& ",pointray) withcolor blue; draw rigorousfearpath(" |
| 58 |
& cstr( tmp ) |
| 59 |
& ",pointray); ", tmp); |
| 60 |
endfor; |
| 61 |
numeric maxn, sparkfac; |
| 62 |
maxn = 0; |
| 63 |
for i=1 upto classnum: |
| 64 |
if hx[i]>maxn: maxn := hx[i]; fi; |
| 65 |
if hy[i]>maxn: maxn := hy[i]; fi; |
| 66 |
if hz[i]>maxn: maxn := hz[i]; fi; |
| 67 |
endfor; |
| 68 |
sparkfac = sparksiz/maxn; |
| 69 |
for j=1 upto classnum: |
| 70 |
draw rp(((j-1)*classtep-1,1+sparkfac*hx[j-1],-1)) |
| 71 |
--rp(((j-1)*classtep-1,1+sparkfac*hx[j],-1)) |
| 72 |
--rp((j*classtep-1,1+sparkfac*hx[j],-1)); |
| 73 |
draw rp((-1,(j-1)*classtep-1,1+sparkfac*hy[j-1])) |
| 74 |
--rp((-1,(j-1)*classtep-1,1+sparkfac*hy[j])) |
| 75 |
--rp((-1,j*classtep-1,1+sparkfac*hy[j])); |
| 76 |
draw rp((-1,1+sparkfac*hz[j-1],(j-1)*classtep-1)) |
| 77 |
--rp((-1,1+sparkfac*hz[j],(j-1)*classtep-1)) |
| 78 |
--rp((-1,1+sparkfac*hz[j],j*classtep-1)); |
| 79 |
endfor; |
| 80 |
doitnow; |
| 81 |
endfig; |
| 82 |
|
| 83 |
end. |