| 1 |
.PS |
| 2 |
# CrullerDPV.m4 |
| 3 |
threeD_init |
| 4 |
NeedDpicTools |
| 5 |
scale = 2.54 |
| 6 |
|
| 7 |
define(`lobe',`(sind(6*(`$1'))+4)/5*2.25') |
| 8 |
|
| 9 |
viewazimuth = 20 # Set view angles in degrees |
| 10 |
viewelevation = 30 |
| 11 |
setview(viewazimuth,viewelevation,0) |
| 12 |
|
| 13 |
dt = 3 # major angle degrees per facet |
| 14 |
ds = 10 # minor angle degrees per facet |
| 15 |
|
| 16 |
tradius = 6 |
| 17 |
define(`cruller',`rot3Dz((`$1')*dtor_, |
| 18 |
sum3D(0,tradius,0,0,Rect_(lobe(`$2'+2*(`$1')),`$2')))') |
| 19 |
|
| 20 |
define(`tvisible',`dot3D(View3D, |
| 21 |
cross3D(diff3D(cruller(`$1'+dt/2,`$2'),cruller(`$1',`$2')), |
| 22 |
diff3D(cruller(`$1',`$2'+ds/2),cruller(`$1',`$2'))))') |
| 23 |
|
| 24 |
# create the arrays and sort |
| 25 |
n = 0 |
| 26 |
for t = dt to 360+dt/2 by dt do { |
| 27 |
for s=ds/2 to 360.1 by ds do { |
| 28 |
if tvisible(t,s) > -0.01 then { |
| 29 |
n +=1 |
| 30 |
t[n] = t |
| 31 |
s[n] = s |
| 32 |
d[n] = dot3D(cruller(t,s),view3D1,view3D2,view3D3) # view distance |
| 33 |
ix[n] = n |
| 34 |
} |
| 35 |
} } |
| 36 |
# prval(n) |
| 37 |
dpquicksort(d,1,n,ix) |
| 38 |
|
| 39 |
# Background |
| 40 |
Bne: (9,6) |
| 41 |
Bsw: (-9,-6) |
| 42 |
B: 0.5 between Bne and Bsw |
| 43 |
iflatex(`line fill_(0.75) \ |
| 44 |
from (Bsw,Bne) to Bsw then to (Bne,Bsw) then to Bne then to (Bsw,Bne)', |
| 45 |
`ShadedPolygon((Bsw,Bne):Bsw:(Bne,Bsw):Bne,,-30, |
| 46 |
0,1,1,1, |
| 47 |
.5,.1,.4,0, |
| 48 |
1,0,0,0) at B') |
| 49 |
# draw the facets |
| 50 |
thinlines_ |
| 51 |
[ |
| 52 |
rgbtohsv(0.6,0.4,0,h,s,v) |
| 53 |
for i = 1 to n do { |
| 54 |
tc = t[ix[i]]; sc = s[ix[i]] |
| 55 |
SE: Project(cruller(tc+dt/2,sc-ds/2)) |
| 56 |
SW: Project(cruller(tc-dt/2,sc-ds/2)) |
| 57 |
NW: Project(cruller(tc-dt/2,sc+ds/2)) |
| 58 |
NE: Project(cruller(tc+dt/2,sc+ds/2)) |
| 59 |
f = ((dcosine3D(3,cruller(tc,sc))/2.25+1)/2)^2 |
| 60 |
hsvtorgb(h,(1-f)*s,1,r,g,b) |
| 61 |
line outlined rgbstring(r,g,b) shaded rgbstring(r,g,b) ifpdf( invis ) \ |
| 62 |
from SE to SW then to NW then to NE then to SE } |
| 63 |
] at B |
| 64 |
|
| 65 |
thicklines_ |
| 66 |
|
| 67 |
.PE |