[ODE] How to calculate X, Y, Z Euler rotation angles from 3d vector direction?
michael kapelko
kornerr at gmail.com
Sat Nov 11 06:05:11 MST 2006
Let me explain what I want with the help of screen shots:
http://kornerr.alfamoon.com/pictures/rot_axis.html
On the first image hinge joint has (0, 1, 1) axis direction.
On the second image hinge joint has (0, 1, 0) axis direction.
I use the (incorrect) formulas to convert the axis direction to Euler
angles:
rot.Y = atan2 (axis.X, axis.Y);
rot.Y *= (180 / M_PI);
if (rot.Y < 0)
rot.Y += 360;
if (rot.Y > 360)
rot.Y -= 360;
float z1 = sqrt (axis.X * axis.X + axis.Z * axis.Z);
rot.X = atan2 (z1, axis.Y);
rot.X *= (180 / M_PI);
if (rot.X < 360)
rot.X += 360;
if (rot.X > 360)
rot.X -= 360;
You can see that the formulas are incorrect on the third image.
So does anyone know the correct formulas?
Thanks.
More information about the ODE
mailing list