🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

3D Rotation Formulas

Started by
1 comment, last by acw83 24 years, 6 months ago
The equations are pretty trivial, and you should be able to derive them yourself with a little trig. BUT, since I'm nice, I'll give them to you.

For rotation around the z-axis:

x' = x cos za - y sin za;
y' = x sin za + y cos za;

For rotation around the x-axis:

y' = y cos xa - z sin xa;
z' = y sin xa + cos xa;

For rotation around the y-axis:

x' = x cos ya + z sin ya;
z' = - x sin ya + z cos ya;

Of course, x', y' and z' are the new coordinates. I'll let you figure out how to plug this into your code. It's not hard, but not as simple as you hoped.

Advertisement
Matrices really just confuse me. So, does anyone have the straight up equations to rotate a point around the x, y, and z axis? This is my ultimate goal:

BOOL RotatePoint(CVector* point, float xa, float ya, float za);
{
point.screen_x = // Rotated x around xa, ya, and xa.
point.screen_y = // Same as above but for y
point.screen_z = // Ditto

return TRUE;
}

Any help would be great! Thanks!

Thanks, you are the man. That was exactly what I was looking for!

This topic is closed to new replies.

Advertisement