# Orientation representation: Is it really true that all representations with 3 values suffer from gimbal lock ?

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

## Recommended Posts

Hi,

unfortunately i have found no solution for my [url="http://www.gamedev.net/topic/597974-unprojection-of-points-homogenous-clip-coords-make-me-perplex/"]other[/url] problem, so I will have to live with that.

But in my quest for the shortest adequate representation of 3D rotations for my diploma thesis I ran into some questions, I can´t answer myself. I will
ask my prof, but I try here too, because I expect that the practical understanding of quaternions and rotations is actually better in the gaming community.

If you are interested: my project is about motion capturing, formulated as an optimization problem with approximate 25 degrees of freedom. So it is really important
to have short representations for rotations (matrices are no option).

My question:

Looking at this[url="http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation"] wikipedia quote[/url]:
[quote]It can be shown that no two-parameter coordinate system can avoid such degeneracy. We can avoid such problems by embedding the sphere in three-dimensional space and parameterizing it with three Cartesian coordinates (here [i]w[/i],[i]x[/i],[i]y[/i]),[/quote]

So analogous we can´t represent a rotation in 3D with 3 values, but...

[quote]Points on the sphere satisfy the constraint [i]w[/i][sup]2[/sup] + [i]x[/i][sup]2[/sup] + [i]y[/i][sup]2[/sup] = 1, so we still have just two [url="http://en.wikipedia.org/wiki/Degrees_of_freedom_%28physics_and_chemistry%29"]degrees of freedom[/url] though there are three coordinates.[/quote]

We can note that one coordinate is always redundant, because w^2 = 1 - x^2 - y^2. Why bother about the w ? Isn´t it a bad approach to store redundant values, which can be inferred easily ?

Actually if we look at quaternion representation there is a compact axis-angle representation hidden in the four values. Actually the first three values x,y,z denote a vector which acts as a rotational axis. The angle is encoded as the axis length. Maximally short and elegant if you ask me.

Back up:
[quote]The point ([i]w[/i],[i]x[/i],[i]y[/i],[i]z[/i]) represents a rotation around the axis directed by the vector ([i]x[/i],[i]y[/i],[i]z[/i]) by an angle [img]http://upload.wikimedia.org/math/a/9/e/a9eb2250f099e88f18e079ac93e75c4d.png[/img][/quote]

We have an axis-angle representation realised by now, with actually three values rather than four and to my best knowledge, axis angle representations do not suffer from gimbal lock. But why is it stated on a regular basis, that there is no gimbal lock free representation with three values and why is a redundant value stored in the quaternion representation ?

I am sure someone can shed some light in my dark

Cheers,
Frederik

##### Share on other sites
I'm not a mathematician, so I may be inexact or even wrong.

1. With x[sup]2[/sup] + y[sup]2[/sup] + z[sup]2[/sup] = 1 and (x, y) given, you still cannot compute a unique z. You are only happy with this if +z and -z have the same meaning. In the case of quaternions it is true that for each orientation in 3D space 2 equivalent quaternions exist, one being the negated version of the other. But due to the square, the sign is lost anyway.

2. A rotation matrix can be interpreted as a basis. Such an interpretation is (AFAIK) not existent for quaternions. Saying "if we look at quaternion representation there is a compact axis-angle representation hidden in the four values" is wrong w.r.t. a geometric interpretation. Of course, you can convert from quaternion to axis/angle (or matrix, or Euler angles, or whatever), so in [i]this[/i] sense it is hidden therein, but I think that isn't the statement behind the sentence.

3. A quaternion need not be of unit length, but only unit-quaternions represent pure rotations. So from the standpoint of the general quaternion, the unit-length is not a must and hence there is no redundancy. Just your usage may introduce this redundancy.

4. Although a 3D axis/angle representation where the angle is encoded in the vector's length is more compact than a quaternion, you also have to consider the operations like concatenation and application onto a vector.

5. AFAIK gimbal lock is a problem of consecutive rotations where a particular rotation becomes worthless because of the previous rotations. This has nothing to do with the number of co-efficients but with the method of rotations one uses to compose the overall rotation. That said, gimbal lock may occur when using quaternions or axis/angle rotations as well; you just have to use them in the same manner as Euler angles are used, for example.

##### Share on other sites
Hi,

[quote]I'm not a mathematician, so I may be inexact or even wrong.[/quote]

Neither am I

[quote]
1. With x[sup]2[/sup] + y[sup]2[/sup] + z[sup]2[/sup] = 1 and (x, y) given, you still cannot compute a unique z. You are only happy with this if +z and -z have the same meaning. In the case of quaternions it is true that for each orientation in 3D space 2 equivalent quaternions exist, one being the negated version of the other. But due to the square, the sign is lost anyway
[/quote]

Well thats interesting. The w value is not completely redundant, but stores a sign, which will disambiguate the dual rotations. Quaternions seem to cover the [i]action [/i]of rotation not only the[i] result[/i], which means not only the end orientation is stored, but also the way taken to reach it.

For me that is not so important, and its totally fine to loose this extra information.

[quote]
2. A rotation matrix can be interpreted as a basis. Such an interpretation is (AFAIK) not existent for quaternions. Saying "if we look at quaternion representation there is a compact axis-angle representation hidden in the four values" is wrong w.r.t. a geometric interpretation. Of course, you can convert from quaternion to axis/angle (or matrix, or Euler angles, or whatever), so in [i]this[/i] sense it is hidden therein, but I think that isn't the statement behind the sentence.
[/quote]

Well there is a geometric interpretation, have a look at the [url="http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation"]wiki[/url]. Quaternion is actually axis/angle, with the axis scaled by some sine of the angle.
Again the quote:

[quote]he point ([i]w[/i],[i]x[/i],[i]y[/i],[i]z[/i]) represents a rotation around the axis directed by the vector ([i]x[/i],[i]y[/i],[i]z[/i]) by an angle [img]http://upload.wikimedia.org/math/a/9/e/a9eb2250f099e88f18e079ac93e75c4d.png[/img][/quote]

[quote]3. A quaternion need not be of unit length, but only unit-quaternions represent pure rotations. So from the standpoint of the general quaternion, the unit-length is not a must and hence there is no redundancy. Just your usage may introduce this redundancy.[/quote]

Right but un-normalised quaternions are not of great use, unlike unnormalised homogenous coordinates !? Or are there other use cases for quaternions ?

[quote]5. AFAIK gimbal lock is a problem of consecutive rotations where a particular rotation becomes worthless because of the previous rotations. This has nothing to do with the number of co-efficients but with the method of rotations one uses to compose the overall rotation. That said, gimbal lock may occur when using quaternions or axis/angle rotations as well; you just have to use them in the same manner as Euler angles are used, for example.[/quote]

Given, but it is often stated that representations with only three values are degenerate at some point.

[quote]It can be shown that no two-parameter coordinate system can avoid such degeneracy.[/quote]
In our case thats 3D.

This doesn´t seem to apply to "axis scaled by angle".

Any more enlightenment ? Actually I am favouring "scaled axis" over eulers at the moment. I believe including w would cause only trouble, since this would require the optimization process to care for the quaternion constraints.

Thanks al lot!
Frederik

##### Share on other sites
[quote]Given, but it is often stated that representations with only three values are degenerate at some point.[/quote]
I've never run across that particular statement (not to say it's not out there somewhere).

In any case, a compressed quaternion represented using three elements should work fine and should not suffer from any degeneracies (IINM). Furthermore, you could probably use Euler angles as well (just using Euler angles to store and transmit orientations and rotations should not introduce problems such as gimbal lock).

Either way, you should be able to represent your orientations/rotations using three elements. (As for the actual memory requirements, that depends on how many bits of precision you need for each element.)

##### Share on other sites
Hi jyk,

[quote]I've never run across that particular statement (not to say it's not out there somewhere).[/quote]

This is from wikipedia. Maybe this is right for angular representations only. But I have definitelty seen relaxations of this sentence stating that 3 parameters are generelly insufficient.

[quote]In the same way the hyperspherical space of 3D rotations can be parameterized by three angles ([url="http://en.wikipedia.org/wiki/Euler_angles"]Euler angles[/url]), but any such parameterization is degenerate at some points on the hypersphere, leading to the problem of [url="http://en.wikipedia.org/wiki/Gimbal_lock"]gimbal lock[/url].[/quote]

I am not too sure about the eulers though. I will try (actually my computer will ) many poses to search for one which minimizes the error to a depth image. So its not completely unlike that the problem with gimbal lock could occur. I have read about character animators who are used to work around gimbal lock I can´t exactly tell so I will try the compressed quaternion form.

Thanks!