- Home /
Yaw Pitch Roll order?
I am trying to obtain the Yaw Pitch and Roll from the quaternion and feed it into an Aerospace application. I want to know how the Euler Angles are processed from a Quaternion, which order and is it okay to get the Euler Angle and feed it to a RHS coordinate system application?
Also I notice that the Pitch ranges only from -90 to + 90 (Gimbal lock / heading changes?). I want to know if I can directly calculate Yaw Pitch and Roll from the Quaternion as follows?
roll = Mathf.Rad2Deg Mathf.Atan2(2.0f (m_localQuat[2] m_localQuat[3] - m_localQuat[0] m_localQuat[1]), (m_localQuat[3] m_localQuat[3] - m_localQuat[0] m_localQuat[0] + m_localQuat[1] m_localQuat[1] - m_localQuat[2] m_localQuat[2]));
pitch = Mathf.Rad2Deg Mathf.Asin(Clamp(2 (m_localQuat[0] m_localQuat[3] + m_localQuat[1] m_localQuat[2], -1.0f, 1.0f)));
yaw = Mathf.Rad2Deg Mathf.Atan2(2.0f (m_localQuat[1] m_localQuat[3] - m_localQuat[2] m_localQuat[0]), (m_localQuat[3] m_localQuat[3] - m_localQuat[0] m_localQuat[0] - m_localQuat[1] m_localQuat[1] + m_localQuat[2] m_localQuat[2]));
The Mathf.Asin2 keeps the pitch in the -90/90 range so I have another equation that can expand the values to -180/180.
Let me know how I can pass rotations successfully? I also feel like Rigidbodies/FixedUpdate and Timescale has a direct impact on sending these values as my output graph doesn't look right when my roll is not 0. I am trying to send the values through a 8MS thread (Trying to interpolate as my Update thread is not fast enough)
Thanks, Lakshmi