Forum: Poser - OFFICIAL


Subject: Gimbal lock

aslaksen opened this issue on May 10, 2006 · 17 posts


aslaksen posted Sun, 14 May 2006 at 8:34 PM

Hi guys,

I just realized that I was wrong. It is not true that the X-rotation always is global (when using YXZ rotation order).

I decided to sit down and really do the math. I wanted to make sense of the experiments conducted by Ronstuff at http://market.renderosity.com/mod/forumpro/showthread.php?thread_id=984280

Summary: When using the YXZ rotation order, Y-rotation is around the local Y-azis, Z-rotation is around the global Z-axis, and X-rotation gives a global rotation, not around the X-axis, but around the axis that results when you apply the Z-rotation to the X-axis. If the Z-rotation is zero, then the X-rotation is global. If the Y-rotation is zero, then the X-rotation is local.

I thought I'd share it with the forum. It may be a bit more math than some of you feel like, but I will try to keep it simple.

I will assume that Poser uses the rotation order YXZ. That means that every rotation is decomposed as

R(V, s) = R(Z, a) R(X, b) R(Y, c).

Here R(V, s) means rotation of s degrees about the vector V. I read products of rotations from right to left. In other words, every rotation can be written as first a rotation around the Y-axis, then around the X-axis and finally around the X-axis. All the rotations are around the GLOBAL axes.

Rotations don't commute, but here is a general product rule

R(V,s) R(W,t) = R(R(V,s)W,t) R(V,s).

If you manage to penetrate the mathematical notation, it simply says that first rotating around W and then around V, is the same as first rotating around V and then rotating around the vector that is obtained when you apply the V-rotation to W.

I will start with a rotation

R(V,s) = R(Z,a) R(X,b) R(Y,c),

and change the Z-rotation to R(Z,a+d). Now

R(Z,a+d) = R(Z,a) R(Z,d) = R(Z,d) R(Z,a),

so

R(Z,a+d) R(X,b) R(Y,c) = R(Z,d) R(Z,a) R(X,b) R(Y,c) =
R(Z,d) R(V,s).

This simply says that changing the Z-rotation from a to a+d adds a global Z-rotation of d. Just like Ronstuff said.

Now let us change the Y-rotation to R(Y,c+d). Then we get

R(Z,a) R(X,b) R(Y,c+d) = R(V,s) R(Y,d).

Now we use the product rule above and get

R(V,s) R(Y,d) = R(R(V,s)Y,d) R(V,s).

But what is R(R(V,s)Y,d)? Again, if you can penetrate the notation, it simply says rotate d degrees about the vector you get when you apply (R(V,s) to the Y-axis. If you think about this, you will see that R(R(V,s)Y,d) R(V,s) simply is the local Y-rotation of d. Again, just like Ronstuff said.

Notice how extra factors at the left (end) give global rotations and extra factors at the right (beginning) give local rotations.

Now let us change the X-rotation to R(X,b+d). Then we get

R(Z,a) R(X,d) R(X,b) R(Y,c),

and if we apply the product rule we get

R(R(Z,a)X,d) R(Z,a) R(X,b) R(Y,c+d) = R(R(Z,a)X,d) R(V,s).

So changing the X-rotation gives a global rotation of d, but not around the X-axis but around the axis that results when you apply R(Z,a) to the X-axis. This again agrees with what Ronstuff said! (Except that there was a typo in his summary, which mixed up Y and Z when describing how the X-axis behaves.)

If zRot is zero, then R(R(Z,a)X,d) = R(X,d) so we get a global X-rotation.

If yRot is zero, then we get R(Z,a) R(X,b) R(X,d), and since the extra term is on the right, it represents a local X-rotation.
 
If you're still alive, you may also want to know that instead of bringing the R(X,d) term to the left to get a GLOBAL X rotation, we can bring it to the right. Some funky application of the product rules gives R(V,s) R(R(Y,-c)X,d), which means that you get a LOCAL rotation around not the X-axis, but the vector you get when you apply a rotation of -c around the Y-axis to the X-axis.

OK, this was probably more than you wanted to know, but I thought it may be of interest to some.

If you want to change this behaviour, you can manipulate the rotation order in the joint editor.

Helmer