10-23-2004, 11:04 PM
Hi!
I'm learning 3D rotating, but I have a litle trouble with my code! I get Overflow all the time, but I can't seem to understand why!! Here is the code:
Please help me! Thank you!
I'm learning 3D rotating, but I have a litle trouble with my code! I get Overflow all the time, but I can't seem to understand why!! Here is the code:
Code:
SCREEN 12
DIM c!(360), s!(360)
points = 7
theta = 1
phi = 1
DIM x(points), y(points), z(points), new.x(points), new.y(points), z2(points), x2(points), y2(points)
FOR angle = 1 TO 360
c!(angle) = COS(angle * 3.14 / 180)
s!(angle) = SIN(angle * 3.14 / 180)
NEXT
x.center = 150
y.center = 150
z.center = 265
FOR i = 0 TO points
READ x(i)
READ y(i)
READ z(i)
NEXT
DO
FOR i = 0 TO points
x2(i) = -x(i) * s!(theta) + y(i) * c!(theta)
y2(i) = -x(i) * c!(theta) * s!(phi) - y(i) * s!(theta) * s!(phi) - z(i) * c!(phi)
z2(i) = -x(i) * c!(theta) * c!(phi) - y(i) * s!(theta) * c!(phi) + z(i) * s!(phi)
new.x(i) = 256 * (x2(i) / (z2(i) + zcenter)) + xcenter
new.y(i) = 256 * (y2(i) / (z2(i) + zcenter)) + ycenter
theta = theta + 1
phi = phi + 1
IF theta = 360 THEN theta = 0
IF phi = 360 THEN phi = 0
NEXT
LOOP UNTIL INKEY$ = CHR$(27)
DATA 50,50,-50
DATA -50,-50,-50
DATA -50,50,-50
DATA 50,-50,-50
DATA 50,50,50
DATA -50,-50,50
DATA -50,50,50
DATA 50,-50,50