-- PolyHackScript.tioga
Read the PolyHack document for an introduction to the theory of the PolyHack, and details of how to use it.
cd; cd PolyHackDemo;
Bringover -p [Cedar]<CedarChest6.0>Top>PolyHack.DF
PolyHack
-- close all viewers on desktop then open in this order:
Left column: (BiScrolling) Poly Hack, (BiScrolling) Poly Hack Control, MispInterpreter, PolyHack.PreLoad. Shove PreLoad contents into MispInterpreter. Close MispInterpreter and PreLoad.
Right column: Watch, this script, PolyHacks
-- Some Tachys:
Set sweep mode, select old Tachy in "PolyHacks", middle click in "(BiScrolling) Poly Hack", then left click (now it starts running), then right click (when bored).
Same for new Tachy.
-- Some Sins:
Set fill mode. Select the do loop from the Sins section of "PolyHacks", and hit the ReadEvalPrint button in the control panel. This runs a demo that repeatedly chooses a random pattern and runs it through one cycle. Any click in the graphics window to stop.
-- Some Polygons:
Set outline mode. Select the do loop from the Polygons section of "PolyHacks", and hit the ReadEvalPrint button in the control panel. This runs a demo that is similar to an XDE DMT. Middle click in the graphics window to stop.
-- Some Spirographs:
Get color viewers going, and put the "(BiScrolling) Poly Hack" in the color column. Make sure the colormap actually has interesting colors in it (not just all grays).
Set trace mode.
Select the red, green, and blue example from the Spirographs section of "PolyHacks", middle click in "(BiScrolling) Poly Hack", then left click (now it starts running), then right click (when completed). Try it this one with sweep mode. You might try composing some traditional (two wheeled) spirographs --- there are some relatively trivial examples in "PolyHacks".
Tachys
--like old Tachy:
(list
(OpenPoly invert
(Constant 450 300)
(Liss 300 150 3.125 90 300 150 3.125 00)
(Constant 300 300)
)
(HalveFirst (OpenPoly invert
(Liss 300 150 3.125 90 300 150 3.125 00)
(Sum
(Liss 300 150 3.125 090 300 150 3.125 000)
(Liss 000 075 12.50 270 000 075 12.50 180)
))
)
(OpenPoly invert
(Constant 300 300)
(Liss 300 200 133.5 30 300 200 133.5 00)
)
)
--like new Tachy
(list
(ListPoly false invert
(cons
(Constant 320 320)
(Series
(list
(Liss 320 162 -01 090 320 162 -01 000)
(Liss 000 108 002 270 000 108 002 180)
(Liss 000 072 -04 090 000 072 -04 000)
(Liss 000 048 008 270 000 048 008 180)
(Liss 000 032 -16 090 000 032 -16 000)
)
)
)
)
(OpenPoly invert
(Constant 320 320)
(Liss 320 300 133.5 20 320 300 133.5 00)
)
)
(list
(ListPoly false invert
(Series
(list
(Constant 200 200)
(Liss 000 243 01 090 000 243 01 000)
(Liss 000 162 -2 270 000 162 -2 180)
(Liss 000 108 04 090 000 108 04 000)
(Liss 000 072 -8 270 000 072 -8 180)
(Liss 000 048 17 090 000 048 17 000)
)
)
)
)
(list
(ListPoly false invert
(Series
(list
(Constant 400 400)
(Liss 000 324 01 090 000 324 01 000)
(Liss 000 216 -2 270 000 216 -2 180)
(Liss 000 144 04 090 000 144 04 000)
(Liss 000 096 -8 270 000 096 -8 180)
(Liss 000 064 17 090 000 064 17 000)
)
)
)
)
(list
(ListPoly false invert
(Series
(list
(Constant 200 200)
(Liss 000 243 002 090 000 243 002 000)
(Liss 000 162 -04 270 000 162 -04 180)
(Liss 000 108 008 090 000 108 008 000)
(Liss 000 072 -16 270 000 072 -16 180)
(Liss 000 048 034 090 000 048 034 000)
)
)
)
)
(list
(OpenPoly invert
(Constant 1 1)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
(Liss 0 0.111111 9 90 0 0.000000 9 0)
(Liss 0 -.090909 11 90 0 -.090909 11 0)
(Liss 0 0.076923 13 90 0 0.076923 13 0)
(Liss 0 -.066667 15 90 0 0.000000 15 0)
(Liss 0 0.058824 17 90 0 -.058824 17 0)
(Liss 0 -.052632 19 90 0 0.000000 19 0)
)
)
)
(list
(OpenPoly invert
(Constant 0 0)
(Sum
(Liss 0 1.000000 1 90 0 1.000000 1 0)
(Liss 0 0.333333 3 90 0 0.333333 3 0)
(Liss 0 0.111111 9 90 0 0.111111 9 0)
)
)
)
(list
(OpenPoly invert
(Constant 0 0)
(Sum
(Liss 0 1.000000 1 90 0 1.000000 1 0)
(Liss 0 1.000000 3 90 0 1.000000 3 0)
(Liss 0 1.000000 9 90 0 1.000000 9 0)
)
)
)
(list
(OpenPoly invert
(Sum
(Liss 0 1.000000 1 225 0 1.000000 1 90)
(Liss 0 1.000000 3 225 0 1.000000 3 90)
(Liss 0 1.000000 9 225 0 1.000000 9 90)
)
(Sum
(Liss 0 1.000000 1 90 0 1.000000 1 0)
(Liss 0 1.000000 3 90 0 1.000000 3 0)
(Liss 0 1.000000 9 90 0 1.000000 9 0)
)
)
)
(list
(OpenPoly invert
(Liss 0 1 2 0 0 1 1 90)
(Liss 0 1 1 90 0 1 2 0)
)
)
Sins
(randbox 5)
(do
()
((not (Stop)))
(prog
(SetPolys (randbox 5))
(Run 360)
(pause 2)
)
)
Polygons
(ListPoly true white (StarHack (Choose 3 9) 40))
(do
()
((not (Stop)))
(let
( ( (vla vlab vlb) (StarHackWithBounds (Choose 4 6) 24) ) )
(prog
(SetPolys (ListPoly true white vlab))
(DrawPolys (ListPoly true white vla))
(DrawPolys (ListPoly true white vlb))
(pause 1)
(Run 40)
(pause 2)
)
)
)
Spirographs
(list
(OpenPoly white
(Spiro
(Point 100 100) 5 (list (Wheel 75 0 0)))
(Spiro
(Point 100 100) 5 (list (Wheel 75 0 120)))
(Spiro
(Point 100 100) 5 (list (Wheel 75 0 240)))
)
)
(list
(OpenPoly white
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 0) (Wheel 100 -1 0 0.75)))
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 120) (Wheel 100 -1 120 0.75)))
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 240) (Wheel 100 -1 240 0.75))))
)
(list
(OpenPoly white
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 180) (Wheel 100 -1 180 0.75)))
(Spiro
(Point 200 200) 5 (list (Wheel 10 0 0))) )
(OpenPoly white
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 0) (Wheel 100 -1 0 0.75)))
(Spiro
(Point 200 200) 5 (list (Wheel 10 0 0))) )
)
(list
(OpenPoly white
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 0) (Wheel 100 -1 0) (Wheel 75 -1 0 0.75)))
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 0) (Wheel 100 -1 0 0.75)))
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 0 0.75)))
)
)
(list
(OpenPoly white
(Spiro
(Point 200 200) 5 (list (Wheel 150 0 0) (Wheel 100 -1 0) (Wheel 75 -1 0 0.75)))
(Spiro
(Point 200 200) 5 (list (Wheel 1 0 0)))
)
)
(list
(OpenPoly red
(Spiro
(Point 245 245) 3 (list (Wheel 240 0 0) (Wheel 160 -1 0) (Wheel 120 -1 0 0.8)))
(Spiro
(Point 245 245) 3 (list (Wheel 240 0 0 0.9)))
)
(OpenPoly green
(Spiro
(Point 245 245) 3 (list (Wheel 240 0 120) (Wheel 160 -1 120) (Wheel 120 -1 120 0.8)))
(Spiro
(Point 245 245) 3 (list (Wheel 240 0 120 0.9)))
)
(OpenPoly blue
(Spiro
(Point 245 245) 3 (list (Wheel 240 0 240) (Wheel 160 -1 240) (Wheel 120 -1 240 0.8)))
(Spiro
(Point 245 245) 3 (list (Wheel 240 0 240 0.9)))
)
)
(list
(OpenPoly white
(Spiro
(Point 250 250) 85 (list (Wheel 100 0 0) (Wheel 75 1 0 0.8)))
(Spiro
(Point 250 250) 01 (list (Wheel 100 0 0) (Wheel 75 -1 0 0.8)))
)
)
(list
(OpenPoly white
(Constant 200 200)
(Spiro
(Point 200 200) 1 (list (Wheel 150 0 0) (Wheel 50 -1 0 0.5)))
)
)
(list
(OpenPoly white
(Constant 200 200)
(Spiro
(Point 200 200) 1 (list (Wheel 150 0 0) (Wheel 100 -1 0)))
)
)
(list
(OpenPoly white
(Constant 250 250)
(Spiro
(Point 250 250) 1 (list (Wheel 243 0 0) (Wheel 81 1 0) (Wheel 27 1 0)))
)
)
(list
(OpenPoly white
(Constant 250 250)
(Spiro
(Point 250 250)
1
(list
(Wheel 243 0 0)
(Wheel 081 1 0)
(Wheel 027 1 0)
(Wheel 009 1 0)
(Wheel 003 1 0)
(Wheel 001 1 0)
)
)
)
)
(list
(OpenPoly white
(Constant 250 250)
(Spiro
(Point 250 250)
1
(list
(Wheel 243 0 0)
(Wheel 027 1 0)
(Wheel 003 1 0)
)
)
)
)
Coloring
(setq rot (Coloring (lambda (x) (fromHSV (rem (div x 6.0) 1.0) 1.0 1.0))))
Experimental
Ptolmic Ananlyses
(ListPoly false white (Series (list
(Constant 0 0)
(Liss 0 1.000000 1 90 0 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
(Liss 0 0.111111 9 90 0 0.000000 9 0)
(Liss 0 -.090909 11 90 0 -.090909 11 0)
(Liss 0 0.076923 13 90 0 0.076923 13 0)
(Liss 0 -.066667 15 90 0 0.000000 15 0)
(Liss 0 0.058824 17 90 0 -.058824 17 0)
(Liss 0 -.052632 19 90 0 0.052632 19 0)
)))
(defun PoolCoefs (freq)
(if
(equal 0 (rem freq 2))
(list 0 0 0 0)
(let
(
(inv (div 1.0 freq))
(xsgn (rem (round (quot (minus freq 1) 2)) 2))
(ysgn (quot (minus 3 (rem freq 6)) 2))
)
(list
(if (equal xsgn 0) inv (minus 0 inv))
90
(mult ysgn inv)
0
)
)
)
)
(defun BoxCoefs (freq)
(if
(equal 0 (rem freq 2))
(list 0 0 0 0)
(let
(
(inv (div 1.0 freq))
(xsgn (rem (round (quot (minus freq 1) 2)) 2))
(ysgn (quot (minus 3 (rem freq 6)) 2))
)
(list
(if (equal xsgn 0) inv (minus 0 inv))
90
(if (equal xsgn 0) inv (minus 0 inv))
(minus 90 (mult 90 freq))
)
)
)
)
(FilteredSeries false white (Generate 20 PoolCoefs) 20 30)
(FilteredSeries false white (Generate 10 BoxCoefs) 0 11)
(PoolCoefs 11)
(Generate 19 PoolCoefs)
Random
(list
(OpenPoly white
(Sum
(Bounce 0 100 2 -3 100 100)
(Liss 0 10 72 90 0 10 72 0)
)
(Sum
(Bounce 0 000 2 3 100 100)
(Liss 0 10 72 90 0 10 72 0)
)
)
)
(list
(OpenPoly invert
(Constant 1 1)
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
(Liss 0 0.111111 9 90 0 0.000000 9 0)
)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
(Liss 0 0.111111 9 90 0 0.000000 9 0)
(Liss 0 -.090909 11 90 0 -.090909 11 0)
)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
(Liss 0 0.111111 9 90 0 0.000000 9 0)
(Liss 0 -.090909 11 90 0 -.090909 11 0)
(Liss 0 0.076923 13 90 0 0.076923 13 0)
)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
(Liss 0 0.111111 9 90 0 0.000000 9 0)
(Liss 0 -.090909 11 90 0 -.090909 11 0)
(Liss 0 0.076923 13 90 0 0.076923 13 0)
(Liss 0 -.066667 15 90 0 0.000000 15 0)
)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
(Liss 0 0.111111 9 90 0 0.000000 9 0)
(Liss 0 -.090909 11 90 0 -.090909 11 0)
(Liss 0 0.076923 13 90 0 0.076923 13 0)
(Liss 0 -.066667 15 90 0 0.000000 15 0)
(Liss 0 0.058824 17 90 0 -.058824 17 0)
)
(Sum
(Liss 1 1.000000 1 90 1 1.000000 1 0)
(Liss 0 -.333333 3 90 0 0.000000 3 0)
(Liss 0 0.200000 5 90 0 -.200000 5 0)
(Liss 0 -.142857 7 90 0 0.142857 7 0)
(Liss 0 0.111111 9 90 0 0.000000 9 0)
(Liss 0 -.090909 11 90 0 -.090909 11 0)
(Liss 0 0.076923 13 90 0 0.076923 13 0)
(Liss 0 -.066667 15 90 0 0.000000 15 0)
(Liss 0 0.058824 17 90 0 -.058824 17 0)
(Liss 0 -.052632 19 90 0 0.052632 19 0)
)
)
)
(ListPoly false invert (Series (list
(Constant 0 0)
(Liss 0 100 1 00 0 100 1 90)
(Liss 0 050 3 90 0 050 3 00)
) -1.0))
(FilteredSeries false invert
(quote
(
(01 1.000000 90 1.000000 0)
(03 -.333333 90 0.000000 0)
(05 0.200000 90 -.200000 0)
(07 -.142857 90 0.142857 0)
(09 0.111111 90 0.000000 0)
(11 -.090909 90 -.090909 0)
(13 0.076923 90 0.076923 0)
(15 -.066667 90 0.000000 0)
(17 0.058824 90 -.058824 0)
(19 -.052632 90 0.052632 0)
)
)
0 20
)
(PowerSeries false invert 6 (div 1.0 2) -1 180)
(PowerSeries false invert 5 (div 2.0 3) -2 180)
(FilteredPowerSeries false invert 7 (div 2.0 3) -2 180 1)
(PowerSeries false invert 6 (div 3.0 4) -3 180)
(PowerSeries false invert 5 (div 4.0 5) -4 180)
(PowerSeries false invert 2 (div 2.0 3) -0.5 0)
(PowerSeries false invert 5 -0.5 2 0)
(setq tau (div twopi 3))
(setq tau2 (mult tau 2))
(setq z0 256)
(setq z1 (mult z0 (exp (mult tau i))))
(setq z2 (mult z0 (exp (mult tau i 2))))
(setq threePSquared (mult 3 z2))
(setq tritest
(let
(
(t1 (div twopi 3))
(z0 200))
(let
(
(t2 (mult t1 2))
(z1 (mult z0 (exp (mult t1 i))))
(z2 (mult z0 (exp (mult t1 i 2)))))
(PtolAnal
(list
(list 0 z0)
(list t1 z0)
(list t1 z1)
(list t2 z1)
(list t2 z2)
(list twopi z2))))))
(PtolSeries false invert 6 tritest 100.0)
(atest -3)
(MapBothInts ln 1 3)
(setq atest
(let
(
(t0 0)
(t1 pi)
(t2 twopi)
(z0 50)
(z1 -50))
(PtolAnal
(list
(list t0 z0)
(list t1 z0)
(list t1 z1)
(list t2 z1)))))
(setq tritest1 (PtolAnal1
(list
(list 0 1)
(list tau 1)
(list tau r)
(list tau2 r)
(list tau2 r2)
(list twopi r2))))
(setq pts (nth 2 (tritest1 2)))
(tritest 3)
(exact 3)
(rem -4 3)
(setq n 1)
(mult (div i n) (minus 1 r) threeRSquared)
(PtolAnalWork 2 pts)
(defun exact (n)
(mult (div i n twopi) (minus 1 r) (nth (plus 1 (rem n 3)) (list 0 threePSquared 0))))
(defun PtolAnal1
(pts)
(let
((last (nth (length pts) pts)))
(let
((closedpts (cons (list (minus (car last) twopi) (nth 2 last)) pts)))
(lambda (n) (list n closedpts)))))
(circpts 256 4)
(lines 200.0 4 12)
(circpts 64 3)