Original Post
How to convert/extract a quaternion to euler angles?
thanks very much...
xee..
void QuatToEuler(const quat_t *quat, double *rotx, double *roty, double *rotz)
{
double sqw;
double sqx;
double sqy;
double sqz;
double rotxrad;
double rotyrad;
double rotzrad;
sqw = quat->w * quat->w;
sqx = quat->x * quat->x;
sqy = quat->y * quat->y;
sqz = quat->z * quat->z;
rotxrad = (double)atan2l(2.0 * ( quat->y * quat->z + quat->x * quat->w ) , ( -sqx - sqy + sqz + sqw ));
rotyrad = (double)asinl(-2.0 * ( quat->x * quat->z - quat->y * quat->w ));
rotzrad = (double)atan2l(2.0 * ( quat->x * quat->y + quat->z * quat->w ) , ( sqx - sqy - sqz + sqw ));
*rotx = rad2deg(rotxrad);
*roty = rad2deg(rotyrad);
*rotz = rad2deg(rotzrad);
return;
}
quote:
Original post by Wudan
Why would you want to? Not to start a quaternion/euler debate, but it should be pointed out that rotations on 2 axii(sp) (the 3rd axis having no rotation value specified) converted to a quaternion and then back will result in a rotation on all 3 axii.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more