4

According to the wikipedia page on Quaternions:

The representations of rotations by quaternions are more compact and quicker to compute than the representations by matrices.

However, I have to admit, I don't fully understand what quaternions are and why they are useful. I have tried to read the article, but I don't understand why defining such a system is useful.

It appears to a define a four dimensional space in which 3 components are imaginary and one is real. Is this attempting to describe spacetime?

Regardless, I was hoping someone here could show how to represent a rotation using both quaternions and matrices and compare the two for me.

  • 1
    Have you looked at the questions already answered on our site? The list of Related questions in the margin is a good starting point. The use of quaternions in representing rotations is covered in many of those. – Jyrki Lahtonen Jul 09 '15 at 13:31
  • Quaternion algebra is used in many places in physics: SU(2) group is used in quantum mechanics and such. AFAICT it is not really to describe spacetime in spite of the apparent 3+1 dimensions. The metric of quaternions is Euclidean (as opposed to Lorentzian). Physicists can say something more precise. – Jyrki Lahtonen Jul 09 '15 at 13:35
  • You can see a symilar question here. http://math.stackexchange.com/questions/435680/quaternions-vs-axis-angle/1071145#1071145 – Emilio Novati Jul 10 '15 at 17:31
  • Quaternions are always more compact: it uses fewer numbers, and then presumably less computation. – rschwieb Jul 16 '15 at 15:38

1 Answers1

11

Consider the wikipedia article's section on performance considerations. For numerical computation, quaternions can be stored as 4 numbers, rather than 9 for a rotation matrix. When combining several successive rotations, quaternions save 17 floating point operations compared to multiplying rotation matrices together. Moreover, in a practical computation, one has to ensure that the quaternion is normalized (or account for its norm in some other way). It's quicker and more efficient to renormalize a quaternion than it is to renormalize a rotation matrix.

The cost for this convenience is that trying to compute a rotated vector from a quaternion takes 26 more floating point operations, so one has to consider whether the bulk of a computation is chaining rotations together or actually computing rotated vectors. For a computation that involves, say, tracking the orientation of a rigid body, that's all about chaining rotations, and quaternions would offer a reduction in memory and arithmetic operations needed.

Quaternions are substantially easier to work with as representations of individual rotations and when you need to chain those rotations together. They're a little more cumbersome to work with when you need to turn that representation into actually computing rotating vectors.

Muphrid
  • 19,902
  • I'm assuming you are thinking about a rotation matrix in 3D. You can get away with storing a vector $\bf u$ and an angle $\theta$ which makes for 4 values, but then you have to do more cumbersome calculations building several matrices on the fly and using linearity of matrix multiplication. – mathreadler Jul 09 '15 at 15:19
  • 3D orientations can be represented by just 2 vectors (6 floats). Ya I suppose Quat and Euler are great for a chain of rotations, but if you have to pack/unpack from/to matrix for each rotation, there's probably no performance to be gained. – user3015682 Jul 24 '20 at 18:13