### Author Topic: Spinning Tetraeder [CMLua]  (Read 727 times)

#### Cybermonkey

`-- tetraeder.yab converted to Luaopoints = {{-1,-1,1},            {1,-1,-1},            {1,1,1},            {-1,1,-1}}         triangles = {{1,2,4},              {2,3,4},              {1,3,4},              {1,2,3}}points={}for i=1,4 dopoints[i]={}endpage = 0phi=0;dphi=0.1;psi=0;dpsi=0.05r=60;g=20;b=0dr=0.5;dg=1.2;db=3;dm=0paper (65535)repeatactivepage (page)cls()phi=phi+dphipsi=psi+dpsi  for n=1, 4 do    points[n][1]=opoints[n][1]*math.cos(phi)-opoints[n][2]*math.sin(phi)    points[n][2]=opoints[n][2]*math.cos(phi)+opoints[n][1]*math.sin(phi)    p2=          points[n][2]*math.cos(psi)-opoints[n][3]*math.sin(psi)    points[n][3]=opoints[n][3]*math.cos(psi)+ points[n][2]*math.sin(psi)    points[n][2]=p2 endr=r+drif (r<0 or r>60) then     dr=-drendg=g+dgif (g<0 or g>60) then dg=-dgendb=b+dbif (b<0 or b>60) thendb=-dbenddm=dm+0.01m=120-80*math.sin(dm)for n=1, 4 do    p1=triangles[n][1]    p2=triangles[n][2]    p3=triangles[n][3]    n1=points[p1][1]+points[p2][1]+points[p3][1]    n2=points[p1][2]+points[p2][2]+points[p3][2]    n3=points[p1][3]+points[p2][3]+points[p3][3]    if (n3>0) then      sp=n1*0.5-n2*0.7-n3*0.6      ink ( hrgb( 60+r+30*sp,60+g+30*sp,60+b+30*sp))      filltriangle (screenwidth()/2+m*points[p1][1],screenheight()/2+m*points[p1][2],screenwidth()/2+m*points[p2][1],screenheight()/2+m*points[p2][2],screenwidth()/2+m*points[p3][1],screenheight()/2+m*points[p3][2])    endendvisualpage (page)page = page + 1 if page > 1 then    page = 0endsleep (12)until keypressed()`