This is a code to rotate a point the in a 3D world which can be useful for 3D games:
Description: The function will rotate a point in its axes.
Caution:
The code will acquire the cosine table sub routine to rotate the point of course in little height speed. [You can refere to Qbasic4.5 Codes 01 high speed Cosine and Sine] under Game Creation board of this forum.
Here is the code:
This will make the arrays and the variables that are required:
Code: Select all
DIM SHARED cose!(360), sine!(360)
DIM SHARED Xrotate!, Yrotate!, Zrotate!
Code: Select all
DEFSNG A-Z
SUB cosine.table
RA = (180 / (22 / 7))
FOR i = 0 TO 360
cose!(i) = COS(i / RA)
sine!(i) = SIN(i / RA)
NEXT i
END SUB
Code: Select all
SUB D3d.rotate (xpROT!, ypROT!, zproT!, xROT%, yROT%, zroT%)
xROT% = xROT% - (INT(xROT% / 360) * 360): IF xROT% < 0 THEN xROT% = xROT% + 360
yROT% = yROT% - (INT(yROT% / 360) * 360): IF yROT% < 0 THEN yROT% = yROT% + 360
zroT% = zroT% - (INT(zroT% / 360) * 360): IF zroT% < 0 THEN zroT% = zroT% + 360
X.X! = xpROT!
Y.X! = (cose!(xROT%) * ypROT!) - (sine!(xROT%) * zproT!)
Z.X! = (sine!(xROT%) * ypROT!) + (cose!(xROT%) * zproT!)
X.Y! = (cose!(yROT%) * X.X!) + (sine!(yROT%) * Z.X!)
Y.Y! = Y.X!
Z.Y! = (cose!(yROT%) * Z.X!) - (sine!(yROT%) * X.X!)
xrotate! = (cose!(zroT%) * X.Y!) - (sine!(zroT%) * Y.Y!)
Yrotate! = (sine!(zroT%) * X.Y!) + (cose!(zroT%) * Y.Y!)
Zrotate! = Z.Y!
END SUB

I think a program in basic can be converted to any other language. useful heh..

So If explanation is needed then ask me.. I know you wouldn’t because you are clever ..

I had created lots of codes during my life and I am happy to share it with you…. If anyone is interested then take it ... and send me at least Personal message..
Are you interested in what I have then goto
http://neonamd64.atspace.com/