• Advertisement
Sign in to follow this  

Coordinated PITCH and YAW rotation?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a problem where I can yaw my model and pitch my model fine, but when I am at 90 degree pitch, and I try to yaw, the model ROLLS instead. Or, if my model is 90 degrees yaw rotation, and I try to pitch, it ends up ROLLing as well. Anyone have example code that demonstrates using coordinated pitch and yaw? Kinda like an airplane in zero gravity using elevators and rudder without ailerons. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
That's kind of the way Euler angles work. However, I'm a little confused because the two symptoms you describe sound like they should be associated with different concatenation orders. Are you saying you get both of these symptoms with the same code, or that you tried switching your code around and get one symptom sometimes and the other symptom other times?

Anyway, I think the former case - where yaw seems like roll when you're heading straight up or down - is typical behavior for a simple flight simulator. However, it sounds like you may actually be wanting 6dof motion, in which case you'll have to ditch Euler angles and use incremental rotations instead. This may or may not be what you're looking for, but I posted code for 6dof motion in this thread some time ago.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
That's kind of the way Euler angles work. However, I'm a little confused because the two symptoms you describe sound like they should be associated with different concatenation orders. Are you saying you get both of these symptoms with the same code, or that you tried switching your code around and get one symptom sometimes and the other symptom other times?


No, the problem is either - or, depending on whether I multiply the Y or X axis first.

Share this post


Link to post
Share on other sites
Quote:
Original post by jackharmon
No, the problem is either - or, depending on whether I multiply the Y or X axis first.
Got it. And yes, those are exactly the results you should expect with Euler angles.

Share this post


Link to post
Share on other sites
judging by your description, you have run into the problem commonly known as "gimbal lock". while a quick google query will releveal a lot of info on the subject the safest way to combat this unwanted effect is to use quaternions for your transformations.

Share this post


Link to post
Share on other sites
Quote:
Original post by benishor
judging by your description, you have run into the problem commonly known as "gimbal lock". while a quick google query will releveal a lot of info on the subject the safest way to combat this unwanted effect is to use quaternions for your transformations.
I'm curious, why is using quaternions safer (with respect to gimbal lock) than using matrices, axis-angle pairs, or direction vectors? Could you clarify?

Share this post


Link to post
Share on other sites
quoting "quaternions don't suffer from some of the problems associated with matrices and floating point math, eg after many matrix multiplications floating point inaccuracies result in a non-orthogonal matrix that has to be rebuilt."

Share this post


Link to post
Share on other sites
Quote:
Original post by benishor
quoting "quaternions don't suffer from some of the problems associated with matrices and floating point math, eg after many matrix multiplications floating point inaccuracies result in a non-orthogonal matrix that has to be rebuilt."
Ok, but what does that have to do with gimbal lock?

Share this post


Link to post
Share on other sites
it's easier to use and it also brings other advantages while it combats it. what is your question thus ?

Share this post


Link to post
Share on other sites
Quote:
Original post by benishor
it's easier to use and it also brings other advantages while it combats it. what is your question thus ?
Well, I do have a reason for pressing the issue :-) As for my question, I'd be interested in hearing how quaternions combat gimbal lock, and why they are more effective at doing so than, say, matrices.

[Edit: If you're just saying that you can avoid gimbal by using quaternions, and they happen to have some other advantages, then that's fine. But if you're saying that quaternions are somehow better specifically at combating gimbal lock than other representations, then I would be interested in hearing a more detailed technical explanation for why you think that is the case.]

Share this post


Link to post
Share on other sites
Well, you could use rotation matrices, but eventually a matrix can be distorted by accumulated errors from floating-point inaccuracy, and end up not being a rotation at all. Quaturnions can be normalised to prevent this.

Share this post


Link to post
Share on other sites
matrices can also be normalized. quaternions are easier to normalize though and they do accumulate less innacuracies

@jyk : I think they combat gimbal lock by having all three axes updated at the same time

Share this post


Link to post
Share on other sites
Quote:
Original post by Jaywalk
Well, you could use rotation matrices, but eventually a matrix can be distorted by accumulated errors from floating-point inaccuracy, and end up not being a rotation at all. Quaturnions can be normalised to prevent this.
Actually, they both will suffer distortion over time, and both can be normalized to correct it; the only real difference is that quaternions degrade a bit slower and can be normalized a bit faster. [Edit: as benishor said.]

@benishor: Ok, the point I was trying to make is that quaternions are in no way better or worse at combating gimbal lock than matrices. They don't do anything magical with respect to rotations, and they don't update the axes any differently then a matrix or vector representation.

The reason I sort of made an issue of it is that this particular bit of misinformation seems to pop up over and over (and over and over and over) here on gdnet and on the web in general, so I feel somewhat compelled to correct it whenever it comes up to try to keep it from spreading further :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement