22

I have been carrying out 2D and 3D operations, including graphics, for many years and have never used quaternions so I don't have a feel for them. I know that they can be used for certain operations that are difficult in Euler angles and also that they can be used to find the rotation required to best fit one set of coordinates (X1, X2...XN, X=(xyz)) onto another (X1', X2'... XN').

Are there places where quaternions are essential? And are there places where they make solutions more elegant or more efficient?

peter.murray.rust
  • 37,407
  • 44
  • 153
  • 217
  • from Wikipedia: Representations of rotations by quaternions are more compact and faster to compute than representations by matrices. – dnagirl Dec 03 '09 at 14:51
  • For those also looking for a link to click: http://en.wikipedia.org/wiki/Quaternion – Phil H Jul 13 '12 at 16:00

6 Answers6

18

They have a smaller memory footprint than rotation matrices and they are more efficient than both matrix and angle/axis representations.

Also:

  • It's extremely easy to interpolate between two quaternions, which is useful for smooth camera movements etc.
  • Unit normalisation of floating point quaternions suffers from fewer rounding defects than matrix representations.
JoeG
  • 12,994
  • 1
  • 38
  • 63
4

Quaternions have many advantages over Euler angles and are often preferable for 3D rotations:

  • Easier (and well-defined) interpolation between quaternions (or: orientations): the resulting movement has constant angular velocity around a single axis, which is often aesthetically more pleasing. This process is called "slerp" and critical for animation/rotation blending. Furthermore, quaternion interpolation does not suffer from Gimbal locks.
  • They are easy to renormalize.

Disadvantages:

  • The main disadvantage is that they require a bit more math and are less intuitive than Euler/Cardanic angles.
  • Compared to affine transformation matrices, Quaternions only contain a rotation, and no translation and scaling.
Ben
  • 1,519
  • 23
  • 39
3

With quaternions you also handle the problem of the gimbal lock. And they are easier to work with when you want to perform arbitrary rotations.

Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
  • 3
    Gimbal lock is only a property of the Euler angles. Independent from the representation of the rotation. – Calmarius Nov 21 '13 at 12:21
2

Pros of quaternions

  1. Fast multiplication
  2. Fast to/from matrix conversion
  3. Avoid additional (from computation) noise (scale , shear) , and represent pure rotation
  4. Simple rotation interpolation, in custom case for real time animation can be used linear interpolation.
  5. Some tricky operations available, fast rotation integration, twist swing decompositions

Cons.

  1. Transformation of vector is not so fast as with 3x3 matrix.
  2. Contains 4 scalar, but compact rotation representation can use only 3.
minorlogic
  • 1,872
  • 1
  • 17
  • 24
1

The advantage of quaternions over matrices is not only faster computation, but mostly because a matrix representation of successive rotations around arbitrary angles eventually give in to dreadful floating-point round-off errors and no longer represent proper, affine rotations. "Restoring" a rotation matrix is computationally more expensive than normalizing a quaternion. Therefore, quaternions should be chosen over pure rotation matrices.

Cecil Has a Name
  • 4,962
  • 1
  • 29
  • 31
  • Quaternions actually take a bit more arithmetic, and successive quats will accumulate roundoff errors just as much as matrices. Their advantage is not carrying around the redundancy found in orthogonal matrices. – DarenW Jan 24 '10 at 00:00
  • 1
    @DarenW While successful multiplications of quaternions will get errors, the difference is that renormalizing them requires a dot-product and a sqaure root. Orthonormalizing a matrix is a far more complex task. – Nicol Bolas Sep 24 '11 at 18:03
0

Compared to Euler angles they are simpler to compose and avoid the problem of gimbal lock.

Compared to rotation matrices they are more numerically stable and the representation (4 numbers) is more compact.

Ray Hulha
  • 10,701
  • 5
  • 53
  • 53