****************************************************************************** ******************3D Formulas in Microsoft QuickBASIC************************* ****************************************************************************** ***********************Uploaded By JEM Software******************************* These formulas work only if you use them correctly! If you have any questions ,complaints, or anything else send it too:Jeremy Easton-Marks 24 Chester St. Nashua, New Hampshire 03060 ______________________________________________________________________________ ROTATION In order to rotate a object you need to know it's x, y, z positions and how many degrees you are going to rotate it by. Rotation around the z axis: sub rotation_Z x% = x% * cos(angle%) - y% * sin(angle%) y% = y% * cos(angle%) + x% * sin(angle%) end sub Rotation around the x axis: sub rotation_X y% = y% * cos(angle%) - z% * sin(angle%) z% = z% * sin(angle%) + z% * cos(angle%) end sub Rotation around the y axis: sub rotation_Y z% = z% * cos(angle%) - x% * sin(angle%) x% = z% * sin(angle%) + x% * cos(angle%) end sub ______________________________________________________________________________ This is a DEMO PROGRAM it is Shareware. You need a screen capable of displaying 256 colors in order to run it. Just cut and paste it into a Rotate.Bas file. DECLARE SUB rotate () DECLARE SUB lie () COMMON SHARED ang% COMMON SHARED ox% COMMON SHARED nx% COMMON SHARED oy% COMMON SHARED ny% COMMON SHARED cenx% COMMON SHARED ceny% cenx% = 160 ceny% = 100 nx% = 75 ny% = 75 SCREEN 13 CLS lie SUB lie DO i% = i% + 1 IF i% = 176 THEN i% = 1 fx% = nx% fy% = ny% - 50 sx% = nx% sy% = ny% + 50 COLOR i% locate 1,1 print "JEM SOFTWARE" LINE (fx%, fy%)-(sx%, sy%) LINE (fx%, fy%)-(cenx%, ceny%) LINE (sx%, sy%)-(cenx%, ceny%) COLOR 0 COLOR 1 ox% = nx% - cenx% oy% = ny% - ceny% SOUND 21000, 0 rotate nx% = nx% + cenx% ny% = ny% + ceny% COLOR 0 LINE (fx%, fy%)-(sx%, sy%) LINE (fx%, fy%)-(cenx%, ceny%) LINE (sx%, sy%)-(cenx%, ceny%) LOOP WHILE INKEY$ = "" END SUB SUB rotate nx% = COS(.125) * ox% + SIN(.125) * oy% ny% = -SIN(.125) * ox% + COS(.125) * oy% END SUB