Charlie Veniot21st February 2022 at 12:35am

```
' BASIC Anywhere Machine version of Spinny Cube by Dean Belfield
' As presented in Paul Dunn's "Spinny Cube" video (https://www.youtube.com/watch?v=bXC9qy4dGeE)
screen 16
dim the as double : dim psi as double : dim phi as double
dim xx as double : dim yy as double : dim zz as double
dim x as double : dim y as double
the = 0.00 : psi = 0.00 : phi = 0.00
dim a(8), b(8) as double
dim xd as double : dim yd as double : dim xo as double : dim yo as double
xd = 0 : yd = 0 : xo = 0 : yo = 0
sd = 1024 : od = 256
sw = 200 : sh = 200
dim shape_pts(8,3), shape(6,4) as double
for i = 0 to 23 : read shape_pts(int(i/3), i mod 3) : next i
for i = 0 to 23 : read shape(int(i/4), i mod 4) : next i
30 the = 0 : psi = 0 : phi = 0
do
gosub 40
the += .01 : psi += .03 : phi -= .02
sleep 0.0125 : cls
loop
40 for i = 0 to 7
xx = shape_pts(i,0) : yy = shape_pts(i,1) : zz = shape_pts(i,2)
y = yy*cos(phi) - zz*sin(phi) : zz = yy*sin(phi) + zz*cos(phi)
x = xx*cos(the) - zz*sin(the) : zz = xx*sin(the) + zz*cos(the)
xx = x*cos(psi) - y*sin(psi) : yy = x*sin(psi) + y*cos(psi)
xx += xo + xd : yy += yo + yd
a(i) = sw + xx * sd / (od - zz )
b(i) = sh + yy * sd / (od - zz )
next i
for i = 0 to 5
x1 = a(shape(i,0)) : x2=a(shape(i,1)) : x3 = a(shape(i, 2)) : x4 = a(shape(i,3))
y1 = b(shape(i,0)) : y2=b(shape(i,1)) : y3 = b(shape(i, 2)) : y4 = b(shape(i,3))
if x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2) <= 0 then
line (x1, y1) - (x2, y2), &hffcc33
line (x2, y2) - (x3, y3), &hffcc33
line (x3, y3) - (x4, y4), &hffcc33
line (x4, y4) - (x1, y1), &hffcc33
end if
next i
return
'
'
'
50 data -20,20,20,20,20,20,-20,-20,20,20,-20,20,-20,20,-20,20,20,-20,-20,-20,-20,20,-20,-20
60 data 0,1,3,2,6,7,5,4,1,5,7,3,2,6,4,0,2,3,7,6,0,4,5,1
```