   Quaternion to Euler Angles
  Hi allI've got this IK problem I posted about a few weeks ago, I think my problem is in the Quat->EulerAngles part, I've tried searching around for a function to do this just in case mine was incorrect, but found none, so now I would like to ask another question in order to try a different approach. Please have in mind that I'm no math expert so make it easy ;)I've got this skeleton system where DOF restrictions of the bones are saved as euler angles, in degrees (e.g. upper arm is restricted to +-45 deg in the z axis, +-90 in the x axis, etc.). So I'm calculating IK rotations of the limbs by using quaternions, but when it comes to verifying DOF restricts, I don't know how to "compare" the current rotation (quaternion) with the DOF restrictions (degrees) in order to make them meet the restrictions, without doing what I'm currently doing, that is converting quats to euler and then viceversa.Currently I'm doing this:void CSkeleton::CheckDOFRestrictions(CBone *link){/// Local Variables ///////////////////////////////////////////////////////////CVertexeuler;// PLACE TO STORE EULER ANGLES/////////////////////////////////////////////////////////////////////////////////if(quat// FIRST STEP IS TO CONVERT LINK QUATERNION BACK TO EULER ANGLESQuatToEuler(&link->quat, &euler);//prev = link->quat;//printf("Ángulo %f,%f,%f\n", euler.x,euler.y,euler.z);// CHECK THE DOF SETTINGSif (euler.x > (float)link->max_rx) euler.x = (float)link->max_rx;if (euler.x < (float)link->min_rx) euler.x = (float)link->min_rx;if (euler.y > (float)link->max_ry) euler.y = (float)link->max_ry;if (euler.y < (float)link->min_ry) euler.y = (float)link->min_ry;if (euler.z > (float)link->max_rz) euler.z = (float)link->max_rz;if (euler.z < (float)link->min_rz) euler.z = (float)link->min_rz;// BACK TO QUATERNIONEulerToQuaternion(&euler, &link->quat);}
Quote:I've tried searching around for a function to do this .. but found noneGoogling for "quaternion euler conversion" netted about 82,000 hits for me.From your description, it sounds like you may be confusing euler angles with direction cosines. Euler angles are not the angles of a vector with respect to a set of axes. Is that what you're trying to limit?If so, direction cosines will probably serve you better.Take a look about half-way down this page.See if that's more the information you're seeking.   ;  Yes I use direction cosines to calculate next movement of the limbs, but my problem is in comparing the current position to restrictions on degrees of freedom for each limb after that position is calculated and set, i.e. if the limb is rotated 50degs on z axis after direction cosines, I need to compare that info with the preset DOF limits, which are stored in euler angles.The problem is I have quaternions for the rotations of the limbs, then need to convert them back to euler angles to check DOF limits.   