1 REM ************************
2 REM *    3D ROTATIONS      *
3 REM ************************
4 REM PORTED TO LM80C BASIC BY
5 REM LEONARDO MILIANI 
6 REM FROM A SOURCE BY "RETRO64" BLOG
7 REM (http://retro64.altervista.org/)
8 REM
10 SCREEN 2:GPRINT "WAIT A WHILE....",8,10
20 DIM X(8),Y(8),Z(8)
30 DIM PF(255),NF(255)
40 DIM CO(100),SI(100)
45 DIM XD(8),YD(8),ZD(8)
50 DIM VX(8),VY(8)
60 OFFSET=64
70 RX=0:REM rotation angle x
80 L=80:FS=200:L=L/2
90 FOR KX=0 TO 6.28 STEP .1
100 CO(RX)=INT(OFFSET*COS(KX))
110 SI(RX)=INT(OFFSET*SIN(KX))
120 RX=RX+1
130 NEXT KX
140 FOR K=0 TO 190
150 PF(K)=(FS*OFFSET)/(K+FS)
160 NF(K)=(FS*OFFSET)/(FS-K)
170 NEXT
180 RX = 0
190 X(1)=-L:Y(1)=-L:Z(1)=-L
200 X(2)=-L:Y(2)=L:Z(2)=-L
210 X(3)=L:Y(3)=L:Z(3)=-L
220 X(4)=L:Y(4)=-L:Z(4)=-L
230 X(5)=-L:Y(5)=-L:Z(5)=L
240 X(6)=-L:Y(6)=L:Z(6)=L
250 X(7)=L:Y(7)=L:Z(7)=L
260 X(8)=L:Y(8)=-L:Z(8)=L
280 CLS
290 C=CO(RX):S=SI(RX)
300 FOR NP = 1 TO 8
310 REM rotation on x axes
320 YT=Y(NP) 
330 YD(NP)=(C*YT-S*Z(NP))/OFFSET:ZD(NP)=(S*YT+C*Z(NP))/OFFSET
340 REM rotation on y axes
350 XT=X(NP):ZT=ZD(NP)
360 XD(NP)=(C*XT+S*ZT)/OFFSET:ZD(NP)=(C*ZT-S*XT)/OFFSET
370 REM rotation on z axes
380 XT=XD(NP):YT=YD(NP) 
390 XD(NP)=(C*XT-S*YT)/OFFSET:YD(NP)=(S*XT+C*YT)/OFFSET
400 REM points projections and translations to screen coordinates
410 IF ZD(NP)>=0 THEN 450
420 VX(NP)=INT(127+(XD(NP)*NF(ABS(ZD(NP))))/OFFSET)
430 VY(NP)=INT(95+(YD(NP)*NF(ABS(ZD(NP))))/OFFSET)
440 GOTO 470
450 VX(NP)=INT(127+(XD(NP)*PF(ZD(NP)))/OFFSET)
460 VY(NP)=INT(95+(YD(NP)*PF(ZD(NP)))/OFFSET)
470 NEXT
480 DRAW VX(1),VY(1),VX(2),VY(2):DRAW VX(2),VY(2),VX(3),VY(3)
490 DRAW VX(3),VY(3),VX(4),VY(4):DRAW VX(4),VY(4),VX(1),VY(1)
500 DRAW VX(5),VY(5),VX(6),VY(6):DRAW VX(6),VY(6),VX(7),VY(7)
510 DRAW VX(7),VY(7),VX(8),VY(8):DRAW VX(8),VY(8),VX(5),VY(5)
520 DRAW VX(1),VY(1),VX(5),VY(5)
530 DRAW VX(4),VY(4),VX(8),VY(8):DRAW VX(2),VY(2),VX(6),VY(6)
540 DRAW VX(3),VY(3),VX(7),VY(7)
550 PAUSE 20
560 RX=RX+1:IF RX>62 THEN RX=0
570 GOTO 280
