%conics.jam
% 3touch
(conicfamily) ((p2y) .exch .def (p2x)
.exch .def (p1y) .exch .def (p1x)
.exch .def (p0y) .exch .def (p0x)
.exch .def (val) 0 .def
10 (p0x p0y .moveto p1x p1y p2x p2y val .conicto .maskstroke (val) val .1 .add .store) .cvx .rept
).cvx .def
(3touch) (.touch .touch .touch).cvx .def
% .touch 15 tcircles
(tcircles) ((ms) .exch .def (y) .exch .def (x) .exch .def
(mr) 0 .def
20 (x y mr circle .maskstrokeclosed
(y) y ms .sub .store
(mr) mr 40 .add .store).cvx .rept
).cvx .def
% .touch 15 tcircles1
(tcircles1) ((ms) .exch .def (y) .exch .def (x) .exch .def
(mr) ms 2 .mul .def
20 (x y mr circle .maskstrokeclosed
(mr) mr 1.5 .mul .store
(y) y mr .sub r .add ms .add .store
).cvx .rept
).cvx .def
% .touch 4 tcircles2
(tcircles2) ((ms) .exch .def .translate
(mr) ms 2 .mul .def
1 .4 .scale
20 (0 0 mr circle .maskstrokeclosed
(mr) mr 1.3 .mul .store
1 1.035265 .scale
0 r mr .sub ms .add .translate
).cvx .rept
).cvx .def
% .touch 2 .copy .setcp 4 tcircles3 .cliparea 10 .getcp rspray
% .touch 4 tcircles3
(tcircles3) ((ms) .exch .def .translate
(mr) ms 2 .mul .def
1 .5 .scale
19 (0 0 mr circle .maskstrokeclosed
(mr) mr 1.5 .mul .store
0 r ms .add .translate
1 1.035265 .scale
0 mr .neg .translate
).cvx .rept
0 0 mr circle .maskstrokeclosed
).cvx .def
% .touch 4 10 tcircles4
(tcircles4) ((deg) .exch .def (ms) .exch .def .translate
(mr) ms 2 .mul .def
1 .5 .scale
19 ( deg .rotate
0 0 mr circle .maskstrokeclosed
deg .neg .rotate
(mr) mr 1.5 .mul .store
0 r ms .add .translate
1 1.035265 .scale
0 mr .neg .translate
(deg) deg .5 .mul .def
).cvx .rept
0 0 mr circle .maskstrokeclosed
).cvx .def
%cx cy radius (just makes a path)
(circle) ((r) .exch .def (cy) .exch .def (cx) .exch .def
cx r .add cy .moveto cx cy r .add cx r .sub cy .arcto
cx cy r .sub cx r .add cy .arcto
).cvx .def
%cx cy radius (just makes a path)
(hcircle) ((r) .exch .def (cy) .exch .def (cx) .exch .def
cx r .add cy .moveto cx cy r .add cx r .sub cy .arcto
.maskstroke
).cvx .def
%3 point arc
(tarc) (.touch .moveto .touch .touch .arcto .maskstroke).cvx .def
(dist1) ((step) .exch .def (ecc) 0 .def
(p2y) .exch .def (p2x)
.exch .def (p1y) .exch .def (p1x)
.exch .def (p0y) .exch .def (p0x)
.exch .def (val) 0 .def
10 (p0x p0y .moveto p1x p1y p2x p2y ecc .conicto .maskstroke
(ecc) ecc .1 .add .store
(p2x) p2x step .add .store
(p2y) p2y step .add .store) .cvx .rept
).cvx .def
(dist2) ((step) .exch .def (ecc) .exch .def
(p2y) .exch .def (p2x)
.exch .def (p1y) .exch .def (p1x)
.exch .def (p0y) .exch .def (p0x)
.exch .def (val) 0 .def
10 (p0x p0y .moveto p1x p1y p2x p2y ecc .conicto .maskstroke
(p2x) p2x step .add .store
(p2y) p2y step .add .store) .cvx .rept
).cvx .def
(dist3) ((step) .exch .def
(p2y) .exch .def (p2x)
.exch .def (p1y) .exch .def (p1x)
.exch .def (p0y) .exch .def (p0x)
.exch .def (val) 0 .def
10 (p0x p0y .moveto p1x p1y p2x p2y .arcto .maskstroke
(p2y) p2y step .add .store) .cvx .rept
).cvx .def
(dist4) ((step) .exch .def
(p2y) .exch .def (p2x)
.exch .def (p1y) .exch .def (p1x)
.exch .def (p0y) .exch .def (p0x)
.exch .def (val) 0 .def
10 (p0x p0y .moveto p1x p1y p2x p2y .arcto .maskstroke
(p2x) p2x step .add .store
(p2y) p2y step .add .store) .cvx .rept
).cvx .def
(rspray)(.translate round .setstrokeend
{.dup 360 .exch .div .cvi {0 0 .moveto 1000 0 .lineto .maskstroke .dup .rotate}.cvx .rept}.cvx
.dosave).cvx .def
(val) .5 .def
(p0xstep) 5 .def
(p0ystep) 5 .def
(p1xstep) 10 .def
(p1ystep) 10 .def
(p2xstep) 10 .def
(p2ystep) 10 .def
(p0xfact) 1.5 .def
(p0yfact) 1.5 .def
(p1xfact) 1.5 .def
(p1yfact) 1.5 .def
(p2xfact) 1.5 .def
(p2yfact) 1.5 .def
% 3touch 10 10 dist5
(dist5) (
(p2step) .exch .def (p1step) .exch .def
setpoints
6 (p0x p0y .moveto p1x p1y p2x p2y val .conicto .maskstroke
(p0y) p0y p0step .add .store
(p1step) p1step p1fact .mul .store
(p1x) p1x p1step .add .store
(p2step) p2step p2fact .mul .store
(p2x) p2x p2step .add .store
(p2y) p2y p2step .sub .store
) .cvx .rept
).cvx .def
%v n d = n*d+v
(linear) (.mul .add).cvx .def
% d s z = z*s/(z+d)
(persp) (.dup 4 1 .roll .mul 3 1 .roll .add .div ).cvx .def
%v n d = d*n*n+v
(quad) (.exch .dup .mul .mul .add).cvx .def
%v n d = d*Sin(n) + v
(sin) (.exch .sin .mul .add).cvx .def
(cos) (.exch .cox .mul .add).cvx .def
%v n d k = k*(d^n)
(exp) (3 1 .roll .exch .exp .mul .add).cvx .def
(setpoints) (
(p2y) .exch .def (p2x) .exch .def
(p1y) .exch .def (p1x) .exch .def
(p0y) .exch .def (p0x) .exch .def
).cvx .def
(showpoints) (pushpoints .setcp .drawto .drawto).cvx .def
(pushpoints) (p0x p0y p1x p1y p2x p2y).cvx .def
%assume points are set. parameter is the count
%6 525 65 525 4 500 setpoints
(values1) (
(val) .4 .def
(dval) .028 .def
(dx0) 0 .def
(dy0) 5 .def
(dx1) 30 .def
(dy1) 5 .def
(dx2) 1.6 .def
(mx2) 4 .def
(dy2) -35 .def
).cvx .def
%assume points are set. parameter is the start, end n
% values1 0 8 newdist
(values2) (
(val) .2 .def
(dval) .05 .def
(dx0) 0 .def
(dy0) 5 .def
(dx1) 25 .def
(dy1) 5 .def
(dx2) 2 .def
(mx2) 10 .def
(dy2) -35 .def
).cvx .def
%values2 0 4 newdist
(newdist) (.exch (n) .exch .def
n .sub 1 .add (
p0x n dx0 linear
p0y n dy0 linear
moveto
p1x n dx1 linear
p1y n dy1 linear
p2x n dx2 mx2 exp
p2y n dy2 linear
val n dval linear
conicto
(n) n 1 .add .store
).cvx .rept
(n) n 1 .sub .store
).cvx .def
(firsthalf) (6 375 65 375 4 350 setpoints values1 0 8 newdist setcopy 8 8 newdist setdraw).cvx .def
%firsthalf value3 0 10 lindist
%firsthalf value4 1 10 newdist
(values4) (
(val) .425 .def
(dval) .05 .def
(dx0) 0 .def
(dy0) 5 .def
(dx1) 30 .def
(dy1) 5 .def
(dx2) 2 .def
(mx2) 64 .def
(dy2) 0 .def
).cvx .def

% 6.0 415.0 305.0 415.0 260.0 70.0
(contVals) (
(dval) 0 .def
(dx2) 128.0 .def
(dy2) 0 .def
).cvx .def
(values3) (
(val) .424 .def
(dval) .05 .def
(dx0) 0 .def
(dy0) 5 .def
(dx1) 80 .def
(dy1) 5 .def
(dx2) 128.0 .def
(mx2) 30 .def
(dy2) 0 .def
).cvx .def
(lindist) (.exch (n) .exch .def n .sub
1 .add (
p0x n dx0 linear
p0y n dy0 linear
moveto
p1x n dx1 linear
p1y n dy1 linear
p2x n dx2 linear
p2y n dy2 linear
val n dval linear
conicto
(n) n 1 .add .store
).cvx .rept
(n) n 1 .sub .store
).cvx .def
%copies points
(setcopy) (
(moveto) ().cvx .def
(conicto) ((val) .exch .def setpoints).cvx .def
).cvx .def
%ordinary drawing
(setdraw) (
(moveto) (.moveto).cvx .def
(conicto) (.conicto .maskstroke).cvx .def
).cvx .def
%shows lines
(setdrawlines) (
(moveto) (2 .copy .moveto .setcp).cvx .def
(conicto) (5 1 .roll 4 .copy 9 -1 .roll .conicto .maskstroke 4 2 .roll .drawto .drawto).cvx .def
).cvx .def
(print) ( .openhornetpd 1 .setstrokewidth 0 10.5 72 .mul .translate -90 .rotate).cvx .def
setdraw
%6 400 65 400 4 350
(values5) (
(val) .4 .def
(dval) .028 .def
(dx0) 0 .def
(dy0) 5 .def
(dx1) 30 .def
(dy1) 5 .def
(dtheta) 10 .def
(fr) 1.5 .def
).cvx .def
%start n theta newdist1
(newdist1) ((theta) .exch .def .exch (n) .exch .def
n .sub 1 .add (
p0x n dx0 linear .dup
p0y n dy0 linear
moveto
p1x n dx1 linear
.sub .neg fr .mul (r) .exch .def
p1x n dx1 linear
p1y n dy1 linear
2 .copy
theta .sin r .mul .sub .exch
theta .cos r .mul .sub .exch
val n dval linear
conicto
(n) n 1 .add .store
(theta) theta dtheta .add .store
).cvx .rept
(n) n 1 .sub .store
).cvx .def
(values6) (
(val) .6 .def
(dval) 0 .def
(dy0) 30 .def
(dx1) 30 .def
(dtheta) 10.9 .def
(fr) 1.5 .def
(d) 500 .def
(s) 100 .def
).cvx .def
%nsweeps theta newdist2
% 6 400 65 400 4 350 setpoints values6 17 5.6 newdist2
(newdist2) ((theta) .exch .def (n) 0 .def
(
p0x .dup
d s 0 n dy0 linear persp p0y .add
.dup 4 1 .roll %p0y p0x p0x p0y
moveto
p1x n dx1 linear %p0y p0x p1x
.dup 4 1 .roll .sub .neg fr .mul (r) .exch .def %r ← (p0x-p1x)*fr leaving p1x p0y
2 .copy
theta .sin r .mul .sub .exch
theta .cos r .mul .sub .exch
val n dval linear
conicto
(n) n 1 .add .store
(theta) theta dtheta .add .store
).cvx .rept
(n) n 1 .sub .store
).cvx .def
(inch) (72 .mul).cvx .def
(frame) ( (frame.pd) .openhornetpd
0 0 .moveto 8.5 inch 0 .lineto 8.5 inch 11 inch .lineto 0 11 inch .lineto 0 0 .lineto
.5 inch .5 inch .movetonext .5 inch 10.5 inch .lineto 8.0 inch 10.5 inch .lineto 8.0 inch .5 inch .lineto .5 inch .5 inch .lineto .drawarea .closepd).cvx .def
(page) (
0 0 .moveto 8.5 inch 0 .lineto 8.5 inch 11 inch .lineto 0 11 inch .lineto .maskstrokeclosed
).cvx .def
(doit) ( 3 200 32.5 200 2 175 setpoints values6 17 5.6 newdist2 6 0 200 rspray).cvx .def
(doitR) (3.5 inch 10.5 inch .translate -90 .rotate doit).cvx .def
(vtec3x) ((in) (24 .mul).cvx .def .openversatecpd .2 .setstrokewidth 3 3 .scale
0 0 45 in 20 in .clipbox 0 8 in .translate doit .closepd).cvx .def
(vtec2x) ((in) (36 .mul).cvx .def .openversatecpd .25 .setstrokewidth 2 2 .scale
0 0 45 in 20 in .clipbox 0 8 in .translate doit .closepd).cvx .def
(quad1) ( .openhornetpd 1 .setstrokewidth 0 10.5 inch .translate -90 .rotate 2 2 .scale doit .closepd).cvx .def
(quad2) ( .openhornetpd 1 .setstrokewidth 0 10.5 inch 2 .mul .translate -90 .rotate 2 2 .scale doit .closepd).cvx .def
(quad3) ( .openhornetpd 1 .setstrokewidth 8 inch 10.5 inch .translate -90 .rotate 2 2 .scale doit .closepd).cvx .def
(quad4) ( .openhornetpd 1 .setstrokewidth 8 inch 10.5 inch 2 .mul .translate -90 .rotate 2 2 .scale doit .closepd).cvx .def
(tx) -2.5 inch .def
(ty) 10.5 inch .def
(quad1) ((quad1.pd) .openhornetpd .2 .setstrokewidth tx ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def
(quad2) ((quad2.pd) .openhornetpd .2 .setstrokewidth tx 8 inch .add ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def
(quad3) ((quad3.pd) .openhornetpd .2 .setstrokewidth tx 16 inch .add ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def

(ty) 20.5 inch .def
(quad4) ((quad4.pd) .openhornetpd .2 .setstrokewidth tx ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def
(quad5) ((quad5.pd) .openhornetpd .2 .setstrokewidth tx 8 inch .add ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def
(quad6) ((quad6.pd) .openhornetpd .2 .setstrokewidth tx 16 inch .add ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def
(ty) 30.5 inch .def
(quad7) ((quad7.pd) .openhornetpd .2 .setstrokewidth tx ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def
(quad8) ((quad8.pd) .openhornetpd .2 .setstrokewidth tx 8 inch .add ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def
(quad9) ((quad9.pd) .openhornetpd .2 .setstrokewidth tx 16 inch .add ty .translate -90 .rotate 3 3 .scale doit .closepd).cvx .def