News:

Welcome to RetroCoders Community

Main Menu

Rotating Cude in FB

Started by ron77, Feb 13, 2023, 12:51 PM

Previous topic - Next topic

ron77

rem rotating cube

screen 13

dim as single rx, l, fs, c, s

dim x (1 to 8) as single
dim y (1 to 8) as single
dim z (1 to 8) as single


dim as single xt, yt

dim np as integer

dim as single vx(1 to 8), vy(1 to 8)

rx = -0.1 : rem rotation angle x

l = 80 : fs = 200 : l = l /2 

label_35:

cls

x(1) = -l : y(1) = -l : z(1) = -l
x(2) = -l: y(2) = l: z(2) = -l
x(3) = l: y(3) = l: z(3) = -l
x(4) = l : y(4) = -l : z(4) = -l
x(5) = -l : y(5) = -l: z(5) = l
x(6) = -l : y(6) = l: z(6) = l
x(7) = l: y(7) = l: z(7) = l
x(8) = l: y(8) = -l: z(8) = l


rx = rx + 0.1 : c = cos(rx): s = sin(rx)



for np = 1 to 8

        rem rotation on x axes

        yt = y(np): y(np) = c*yt-s*z(np): z(np) = s*yt + c*z(np)
        


        rem rotation on y axes


        xt = x(np): x(np) = c*xt+s*z(np): z(np)=-s*xt+c*z(np)
        


        rem rotation on z axes


        xt = x(np) :x(np)=c*xt-s*y(np) : y(np) = s*xt+c*y(np)
    


        rem points projections and translations to screen coordinates



        vx(np) = 160 + (x(np)*fs)/(z(np)+fs)
        vy(np) = 100 + (y(np)*fs)/(z(np)+fs)

next 


line (vx(1), vy(1))-(vx(2),vy(2)),2 : line (vx(2), vy(2)) - (vx(3), vy(3)), 2
line (vx(3), vy(3))-(vx(4),vy(4)),2 : line (vx(4), vy(4)) - (vx(1), vy(1)), 2
line (vx(5), vy(5))-(vx(6),vy(6)),2 : line (vx(6), vy(6)) - (vx(7), vy(7)), 2
line (vx(7), vy(7))-(vx(8),vy(8)),2 : line (vx(8), vy(8)) - (vx(5), vy(5)), 2
line (vx(8), vy(8))-(vx(5),vy(5)),2 : line (vx(1), vy(1)) - (vx(5), vy(5)), 2
line (vx(4), vy(4))-(vx(8),vy(8)),2 : line (vx(2), vy(2)) - (vx(6), vy(6)), 2
line (vx(3), vy(3))-(vx(7),vy(7)),2 

sleep 50


goto label_35

You cannot view this attachment.