Need Help with 3D rotations

Started by
2 comments, last by Hooden 24 years, 8 months ago
I think you are messed up with formulas.
I use the following:
- Around X axis
y1:=cbuffer.Y*Cos(xang)-cbuffer.z*sin(xang);<BR>z1:=cbuffer.Y*Sin(xang)+cbuffer.z*cos(xang);<BR>cBuffer.Y:=y1;<BR>cBuffer.Z:=z1;<P>and soon…<P>FlyFire/CodeX<BR> <A HREF="http://codexorg.webjump.com" TARGET=_blank>http://codexorg.webjump.com</A>
Advertisement
Thanks for the reply, but thats the same thing in a different form. I figured it out: its strange: all i did was change all my variables to doubles and it magically worked.
Thanks for reading this. I am working on a 3D engine and i cant get my rotations working. When I press the key to start the z axis rotation, the square goes back into the z(the z value increases). And when i do a x or y axis rotation, the z value decreases(it comes towards the screen). Here are the formulas that i am using:

X:
-----
temp_y = (rect_3d.vert.y*cos(x_ang)) + (rect_3d.vert.z*sin(x_ang));<BR> temp_z = (rect_3d.vert.y *-sin(x_ang)) + (rect_3d.vert.z*cos(x_ang));<BR> <BR> rect_3d.vert.y = temp_y;<BR> rect_3d.vert.z = temp_z;<P>Y:<BR>—–<BR>temp_x = (rect_3d.vert.x*cos(y_ang)) + (rect_3d.vert.z*-sin(y_ang));<BR> temp_z = (rect_3d.vert.x *sin(y_ang)) + (rect_3d.vert.z*cos(z_ang));<BR> <BR> rect_3d.vert.x = temp_x;<BR> rect_3d.vert.z = temp_z;<P>Z:<BR>—–<BR>temp_x = (rect_3d.vert.x*cos(z_ang)) + (rect_3d.vert.y*sin(z_ang));<BR> temp_y = (rect_3d.vert.x*-sin(z_ang)) + (rect_3d.vert.y*cos(z_ang));<BR> <BR> rect_3d.vert.x = temp_x;<BR> rect_3d.vert.y = temp_y;<P>——–<BR>Any help would be appreciated, and yes i know i should use matrices.<BR>

Just goes to show you... unless memory is *really* tight, use doubles!

Btw, that code is basically a matrix multiplication, just unrolled.

Have fun,

White Fire

This topic is closed to new replies.

Advertisement