Gimbal Lock

Started by
5 comments, last by CDProp 15 years, 1 month ago
I was wondering, let's suppose you are using Euler rotations, and you've chosen a certain rotation order that you cannot change on a case-by-case basis. Does this actually make it impossible to achieve certain orientations? Or is there a tricky way to achieve an orientation that, at first glance, seems impossible? For instance, if I'm using a z/x/y rotation order (which I've found to be nice for mouselook/FPS camera control), and I have a flat object that is aligned such that it is coplanar with the xz plane: And I want to orient it thusly: It seems it would be nearly impossible to do, if not completely impossible. Rotating it by 90 degrees on the x-axis aligns the object's local y-axis with the world's z-axis, and its local z-axis with the world's y-axis. Since the z-rot happens before the x-rot, then any rotation on the z and y will produce essentially the same result. I'm trying to think of an alternate way of getting that orientation, but I can't seem to do it.
Advertisement
Just to help in giving a more specific answer, which axis is which is your image? Is the red axis 'x' and the green axis 'z'? Also, which direction is positive and which is negative?
Mathematically speaking, every rotation can be described by an Euler angles. Gimbal lock doesn't cause some rotations to be impossible. Rather gimbal lock refers to the fact that some previous rotations can render a later rotation axis to be aligned with one of the previous rotation axes so that if your rotations are built solely in terms of incrementing or decrementing the angle values in an Euler sometimes the angle values in the later rotations have no effect.
Thanks for the info. Is that true even with a pre-determined rotation order? If so, I guess I just suffer from a lack of imagination. I can't seem to figure out how to get that orientation using the rotation order that I'm stuck with (z/x/y).

In that image:

x: red line, positive points to the right
y: no line, positive points upward
z: green line, positive points towards the top
I think your rotation will be something like 90/90/45

Edit: Actually, are you applying each of the transformations in world space, or in the local space? The transformation you want could also be something like 90/45/90...try different combinations like that to see what works.

My vote is for 90/30/90 (signs unspecified - also, 30 is just a guess, but it looks about right). So basically the same as Vorpy's second suggestion.

And yes, it can be a little tricky to work out in your head :)
Oh man, yeah, sorry. I forgot to mention that this is in world coordinates. With that said, you guys have helped a lot and I was able to find the correct rotation (-100, 90, -90).

This topic is closed to new replies.

Advertisement