Yaw + Pitch = Roll

Started by
12 comments, last by Fingers_ 14 years, 5 months ago
I am currently coding a space sim and have found that anytime you rotate a Quaternion in the Yaw axis and in the Pitch Axis at the same time you also get a Roll Rotation. Is there anyway to avoid this? I am doing my Rotations in the order Roll,Pitch, then Yaw, but it doesn't help. I have seen the same issue in some games as well. Is this a product of using Quaternions or is it a nature of the beast issue?
Advertisement
That depends on what you mean by "you also get a roll rotation". Can you give an example of a set of angles to yaw and pitch which produce a roll? Also, when you say your ordering is "roll, pitch, then yaw", is that world-space order or object-space order?
if you pitch 45 degrees and yaw 45 degree at the same time your roll equals 45 degrees as well without actually rolling.
It sounds like you're yawing and pitching out of order.
I have tried yaw then pitch and pitch then yaw same results.
If you get the same results then you're definitely doing it wrong (read: in an order-independent way). Y-then-P and P-then-Y should NEVER produce the same results. Post your code.
Quote:I have tried yaw then pitch and pitch then yaw same results.
If you're building your orientation using 'from scratch' Euler angles in the usual way, then one of the above orders should be giving you the desired results (i.e. no roll). Can we see some code?

Keep in mind that with true 6DOF motion (where rotations are applied incrementally about the object's local axes), accumulated yaw and pitch can (and usually will) result in perceived roll. This is the expected behavior in this case, but it can be countered by adding an 'autoleveling' feature (as in the Descent games).
Here you go. I would love to find an answer to the roll induction issue. I hope this helps.

CISQuaternion Temp = *this;		if(dRoll != 0.0)		{			CISQuaternion Roll;			Roll.FromAngleAxis(dRoll, Temp * CISVector::s_UNITZ);			*this = *this * Roll;			Normalize();		}		if(dYaw != 0.0)		{			CISQuaternion Yaw;			Yaw.FromAngleAxis(dYaw,Temp * CISVector::s_UNITY);			CISQuaternion Temp = *this;			*this = *this * Yaw;			Normalize();		}		if(dPitch != 0.0)		{			CISQuaternion Pitch;			Pitch.FromAngleAxis(dPitch,Temp * CISVector::s_UNITX);			CISQuaternion Temp = *this;			*this = *this * Pitch;			Normalize();		}
How is this function used? Do you start with a 'fresh' quaternion each time (i.e. identity), or do you start with a quaternion representing the current orientation of the object?
current orientation I tried tracking the cumulative angle changes but it got messy fast.

This topic is closed to new replies.

Advertisement