Skip to main content
GameDev.net gamedev.net
🔒 Locked

is there any detailed mathematical explanation for the GIMBAL LOCK

Started by feverzsj Aug 13, 2006 at 8:12 AM 20 replies 3.5k views
Original Post
feverzsj
feverzsj
it is not easy to understand it by using a gyro. i found it seems like doing nothing with the camera in the 3d computer graphic . so i am look for some mathematical explanation for the GIMBAL LOCK
atultuff
atultuff
google it ! and with it also look for "quaternions rotations" while you 're at it
there are some really great articles

if you still need help , post again !!
feverzsj
feverzsj
yeah
google is great
but can you give me some relative keywords.
i've try many keywords, but just puzzle me more.
Zakwayda
Zakwayda
Quote:
Original post by atultuff
google it ! and with it also look for "quaternions rotations" while you 're at it
there are some really great articles
Be aware that a good portion of the information about quaternions available online is at best misleading and at worst simply incorrect, so take what you read with a grain of salt.

In short, gimbal lock can occur with Euler angle rotations, specifically when constructing an orientation from three sequential rotations about the global axes. If the second of these rotations happens to be 90 degrees, the first and third rotations will appear to take place about the same axis.

If you wish to avoid gimbal lock, make the orientation persistent rather than creating it from scratch each time, and update it incrementally. For the record, whether you use matrices or quaternions is completely incidental; the properties of the two are exactly the same with respect to the gimbal lock problem.
feverzsj
feverzsj
Quote:
Original post by jyk

If you wish to avoid gimbal lock, make the orientation persistent rather than creating it from scratch each time, and update it incrementally. For the record, whether you use matrices or quaternions is completely incidental; the properties of the two are exactly the same with respect to the gimbal lock problem.



you mean the quaternions also has the gimbal lock problem??

SiCrane
SiCrane
If you use quaternions incorrectly, you can still have gimbal lock. For example, if you replace euler angles by three quaternions that are still representative of yaw, pitch and roll, you'll still have gimbal lock.
feverzsj
feverzsj
Quote:
If the second of these rotations happens to be 90 degrees, the first and third rotations will appear to take place about the same axis.

does the gimbal lock only happen in the above case?
that seems like working on the rotation matrices,but it's not easy to imagine on a coordinate system.If i rotate a vector(0,1,0) around axes y,is that a gimbal lock??
what do you mean by "the first and third rotations will appear to take place about the same axis", and which axes will be???
how does the gimbal lock affect a 3d graphic program??
as it happens , what dose it look like in a practical example(such as a 3d demo)???
Mastaba
Mastaba
Take 3 sticks and tie them together to form a set of 3D axes. Now, manipulate it. Rotate it about each axis (maybe add a piece of paper with the axis name on each) and take note of where each rotation takes place in space.
feverzsj
feverzsj
Quote:
Original post by Mastaba
Take 3 sticks and tie them together to form a set of 3D axes. Now, manipulate it. Rotate it about each axis (maybe add a piece of paper with the axis name on each) and take note of where each rotation takes place in space.


each rotation is ok , nothing like gimbal lock happen
Zakwayda
Zakwayda
Quote:
Original post by feverzsj
Quote:
Original post by Mastaba
Take 3 sticks and tie them together to form a set of 3D axes. Now, manipulate it. Rotate it about each axis (maybe add a piece of paper with the axis name on each) and take note of where each rotation takes place in space.


each rotation is ok , nothing like gimbal lock happen
Remember, each rotation is about the original unrotated global axis. This can be a little hard to visualize with the method proposed above.
Mastaba
Mastaba
Quote:
Original post by jyk
Quote:
Original post by feverzsj
Quote:
Original post by Mastaba
Take 3 sticks and tie them together to form a set of 3D axes. Now, manipulate it. Rotate it about each axis (maybe add a piece of paper with the axis name on each) and take note of where each rotation takes place in space.


each rotation is ok , nothing like gimbal lock happen
Remember, each rotation is about the original unrotated global axis. This can be a little hard to visualize with the method proposed above.


Actually, if you rotate around the rotated ones it does becomes clear. Rotate around x by a small amount, then rotate 90 degrees around y', then rotate a small amount around z". Then compare where z" is when you rotate around it to where x was when you first rotated around it.
Zakwayda
Zakwayda
Quote:
Original post by Mastaba
Actually, if you rotate around the rotated ones it does becomes clear. Rotate around x by a small amount, then rotate 90 degrees around y', then rotate a small amount around z". Then compare where z" is when you rotate around it to where x was when you first rotated around it.
Perhaps I'm misunderstanding, but I'd have to say that performing a sequence of local-axis rotations that results in one axis being where another used to be is not an example of gimbal lock.

Consider the sequence of global-axis rotations X->Y->Z, and let the Y rotation value be fixed at 90 degrees. As long as the Y rotation is 90 degrees, any change in the value of the X or Z rotation will result in a perceived rotation about the same axis; this is gimbal lock.
Mastaba
Mastaba
Quote:
Original post by jyk
Quote:
Original post by Mastaba
Actually, if you rotate around the rotated ones it does becomes clear. Rotate around x by a small amount, then rotate 90 degrees around y', then rotate a small amount around z". Then compare where z" is when you rotate around it to where x was when you first rotated around it.
Perhaps I'm misunderstanding, but I'd have to say that performing a sequence of local-axis rotations that results in one axis being where another used to be is not an example of gimbal lock.

Consider the sequence of global-axis rotations X->Y->Z, and let the Y rotation value be fixed at 90 degrees. As long as the Y rotation is 90 degrees, any change in the value of the X or Z rotation will result in a perceived rotation about the same axis; this is gimbal lock.


Right, but the example shows how you lose a degree of freedom.
Atash
Atash
think about having two sets of coordinate axis. One set can be considered 'local', as in local to the orientation of what you're rotating. The other set can be considered 'global', as in, the world's natural axis (just for a moment, think of it that way. The world is flat right now >_<)

Now, when you have those two sets of axis, imagine that they are standing up aligned, perfectly without an issue. If you take the local axis, and rotate it around 90 or -90 degrees around it's local y-axis, you'll find now that the x-axis is aligned perfectly with the z-axis. Now, the problem is now that if I continued to rotate the object by euler angles (rotating around the global axis) while the local x-axis are aligned with the z-axis, then when I rotate around the global z-axis, I am in fact rotating around the local x-axis, thus having no influence on which way the local x-axis is pointing! (remember that when you rotate around a certain axis, that axis doesn't move. The contra of that statement is true as well.) Okay, now we have a problem... One of our rotational axis has gone caput! Gimbal Lock has totally screwed us over.
After ArgumentP1: What was it about?P2: Something involving a chair, a cat, and a rubber ducky...
feverzsj
feverzsj
thx everybody
after a long time searching ,reading, thinking
i think (maybe) i have got the point.
i'll try to explain what i think a gimbal lock is.

originally, you can find the gimbal lock when you make one axes aligned with another one in a gyro with three gimbals.
gimbal4.gif

just like what show in the image,we got a two-axis system instead of a three axis system, lost one degree of freedom.

but in a 3d graphic system, it can not be easy to imagine the gimbal lock as above.

As Atash's reply, using two sets of coordinate axis one called local,and another
called global.

because the gimbal lock is a special problem in euler angles based system,
we need talk about the euler angles.

Euler angles describe orientation as three rotations about three mutually perpendicular axes.
Yeah ,the "orientation" ,not "direction",that's one key.

now let's make our camera an euler angles device , just fix the camera on the origin of the local coordinate, camera heads the local +z axes and so on.
the whole device makes the camera can face to any orientation by three rotations around three local axes.

then ,when you've determinated some rotation order,how does the camera rotate?
it rotates aroud the local axes ,and because the camera is fixed on
the local coordinate, so the local coordinate turns around with the camera.
that's anothe key.

that is what a euler angles system actually looks like.

now rotate it.
If the second of these rotations happens to be 90 degrees, the first and third rotations will appear to take place about the same local axis.
as a result, what three rotations have done is the same as what two rotations can do.
lost one drgree of freedom, a gimbal lock comes out.

but when you try to confirm the orientation of the camera in the global coordinate, we replace the euler angles(the angular displacement when rotate around the local axes as above) by three angles (say cam_x,cam_y
and cam_z) ,they are the angular displacement when you rotate the camera(or local coordinate) around three global axes.

what's the difference?
actually nothing different,(cam_x,cam_y, cam_z) is just a implicit form of euler angles.
that is to say we can also confirm any orientation with these three angles.

befor rotation ,we need initialize the orientation of camera, just make two coodinates aligned.

now,we rotate it by some order.
you'll find if the second of these rotations happens to be 90 degrees, the first and third rotations will appear to take place about the same local axis.
yeah ,it is the "local axes".
when you rotate aroud the global axes, mind the rotation state of the local axes, you'll find the phenomena just like what i talk above, a gimbal lock.



that is just what i've known about the gimbal lock.
hu... such long...
feverzsj
feverzsj
but what will happen in a 3d demo when gimbal lock occurs???
feverzsj
feverzsj
someone gotta help me
Zakwayda
Zakwayda
Quote:
Original post by feverzsj
someone gotta help me
What help do you need exactly?

Whether gimbal lock is 'bad' depends on the context. If you wish to avoid gimbal lock, maintain your orientation incrementally rather than constructing it from scratch using Euler angle rotations.

If you need more specific advice than that, you should probably tell us exactly what you're trying to do, and then perhaps we can recommend an appropriate rotation representation.
feverzsj
feverzsj
Quote:
Original post by feverzsj
but what will happen in a 3d demo when gimbal lock occurs???



i just want to know the actual phenomenon of gimbal lock when it occurs in a 3d demo
JohnBolton
JohnBolton
One effect of gimbal lock is that rotations no longer seem to rotate correctly. Another effect is that certain rotations become impossible (hence the name gimbal lock).
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.