(Things.JaM By Stolfi July 26, 1983 12:00 am) = (util.jam) .run (graphics.jam) .run (griffin.jam).run (color8.bcd).loadbcd (random) { (ranSeed) ranSeed ranConst .add ranMult .mul .dup .cvi .sub .store ranSeed } .cvx .def (ranSeed) 0.3322107 .def (ranConst) 0.3322107 .def (ranMult) 31.12343 .def (randomDir) ( gives a random vector in the unit ball) { {random random random 3 .copy 3 {.dup .mul 3 1 .roll} .cvx .rept .add .add .dup .dup 1 .gt .not .exch 0.000001 .lt .not .and {1 .exch .sqrt .div scale3 .exit} .cvx .if .pop .pop .pop .pop} .cvx .loop } /xdef (scale3) (takes x y z s, and multiplies x,y,z by s. ) {.dup 4 .index .mul .exch .dup 4 .index .mul .exch 3 .index .mul 6 3 .roll .pop .pop .pop} /xdef (.dot) { 2 .copy .setcp .drawto} .cvx .def 300 200 .translate 100 100 .scale -1 -1 1 1 black .drawbox blue 0 0 .dot red (ellipse) (create an elliptical path of given half-width and half-height centerd at origin) {(hht43) .exch 4. .mul 3. .div .def (hwt) .exch .def hwt .neg 0 .moveto hwt .neg hht43 hwt hht43 hwt 0 .curveto hwt hht43 .neg hwt .neg hht43 .neg hwt .neg 0 .curveto} /xdef (circle) (create a circular path of given radius centerd at origin) {.dup (rad43) .exch 4. .mul 3. .div .def (rad) .exch .def rad .neg 0 .moveto rad .neg rad43 rad rad43 rad 0 .curveto rad rad43 .neg rad .neg rad43 .neg rad .neg 0 .curveto} /xdef (bdot) (Draw a circle of radius bdotRad at the given position) {.pushdc .translate bdotRad circle .drawarea .popdc} /xdef (bdotRad) 0.1 .def