# Yaw + Pitch = Roll

This topic is 3171 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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?

##### Share on other sites
if you pitch 45 degrees and yaw 45 degree at the same time your roll equals 45 degrees as well without actually rolling.

##### Share on other sites
It sounds like you're yawing and pitching out of order.

##### Share on other sites
I have tried yaw then pitch and pitch then yaw same results.

##### Share on other sites
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.

##### Share on other sites
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).

##### Share on other sites
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();		}

##### Share on other sites
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?

##### Share on other sites
current orientation I tried tracking the cumulative angle changes but it got messy fast.

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 32
• 41
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631742
• Total Posts
3001987
×