# Why do people use quaternions?

I have been using them as a black box for a while, I'm just learning about of the maths but I'd just like some definitive answers to this question.

So far the only benefit I've come across personally is the ability to SLERP between two angles - to achieve the same effect with a vector you need quite an ugly work around (intrinsically linking 0 and 2PI together).

• SLERP is not just interpolation between two angles: it can be done easily with matrix too. It can interpolate between two arbitrary orientations which is much more complex when done with matrixes. – Calmarius Nov 15 '13 at 18:40

Quaternions solve a few problems elegantly:

• They are as compact as axis-angle representations (4 scalar values)
• They are easily converted to and from matrix representations
• Interpolation works from any start to end angle without special casing
• They never exhibit gimbal lock

You can get around these issues with other representations, but quaternions are a good fit for their algorithmic simplicity and performance.

• this is EXACTLY what I was looking for! – SirYakalot Feb 8 '12 at 18:49
• @Kai Interpolation works from any start to end angle without special casing, there is actually a special case, when they are not on the same hemisphere of the hypersphere, this is actually a special case that you have to consider, since there are always 2 directions to interpolate to the target and you want to pick the right one – Maik Semder Feb 9 '12 at 12:11
• @Kai They never exhibit gimbal lock - that is not quite true. They can, just multiply q(Xaxis, 0) * q(YAxis, 90) * q(Zaxis, 20). True is, they can be used to avoid gimbal lock, but so can matrices, axis-angles and others. So that is not a unique property of quaternions. In fact you can do that with most of the rotation representations, but euler-angles. The only true message here can be "Euler engles suffer from gimbal lock", but it can be avaoided by a lot of other rotation representations, not only quaternions. – Maik Semder Feb 9 '12 at 12:19
• Neither is the performance of a quaternion generally better in all cases, for instance it is faster to rotate a vector using a 3x3 matrix than using a quaternion. Here is an interesting paper about it. – Maik Semder Feb 9 '12 at 14:33

The SLERP usage you mention is a specific case of a more general attribute of quaternions: you can smoothly interpolate between different rotation values.

When interpolating the rotation values of euler angles you get weird looking movements, and there just isn't logically any way to interpolate the values of axis-angle rotations (well, aside from two different angles around the same axis).

• +1. One can interpolate between (w1,alpha1) and (w2, alpha2) by converting these angle-axis representations to quats and then employing SLERP. Of course, one can do such a thing via a Bezier/de Casteljau scheme/ spline scheme and use a "polygon/set" of key quaternions in such a way and come up with a complicated rotation. This is perhaps the one and only thing that quaternions do more naturally than other representations since SLERP and multiSLERP or their variations (NLERP, SQUAD) come up with intermediate rotation axis/angle pairs that lie on a geodesic/shortest rotation path. Kudos. – teodron Apr 2 '12 at 7:48