What is a Quaternion?

996 views

What in the world is a Quaternion and how do I understand IT?
Throw me everything you know about it.

In: Mathematics

3 Answers

Anonymous 0 Comments

A quaternion is a way to represent a rotation in 3 dimensions.

Quaternions have many advantages over other representations like yaw, pitch, roll, for example they can be made unique^[1] and they aren’t subject to [gimbal lock](https://en.wikipedia.org/wiki/Gimbal_lock)^[2].

Quaternions represent rotations using an [axis and an angle](https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation). They are composed of 4 numbers: usually named X, Y, Z and W. X, Y and Z represent the axis (as a 3D vector), and W is `cos(angle / 2)`.

**[edit]** Quaternion have a “double cover”. They reset after 720°, not 360°. This can make them tricky to use in some situations^[3] (since orientations that appear close can be more than 360° apart).

*************

[1] Which means that every rotation is represented by exactly one quaternion.

[2] Gimbal lock happens when you lose one one degree of freedom due to your orientation. For example, when using yaw pitch and roll, if you pitch up to 90° yaw and roll becomes the same thing which makes everything harder.

[3] [This is what can happens if you aren’t careful when dealing with double cover.](https://www.youtube.com/watch?v=2UEzhenX8IM)

Anonymous 0 Comments

Most basically, a quaternion is what you get if you ask ‘what if there were three imaginary numbers?’

With 1 imaginary number, you get the result i²=-1

With 3 imaginary numbers, you still get i²=-1, but you also get j²=-1 and k²=-1

Furthermore, the imaginary numbers multiply to get each other:

i*j=k, j*k=i, k*i=j. However, multiplication is no longer commutative, meaning that multiplying in a different order gives you a different value: j*i=-k, k*j=-i, i*k=-j

A Quaternion has components, the real component and 3 imaginary ones.

Quaternions have been used as an alternative to vectors. You can represent a vector as a purely imaginary quaternion by putting the x component in front of the i, y component in front of the j, and z component in front of the k (This is why, for example, you often see vectors as having i,j, and k components instead of x,y,z), then multiplying two such quaternions will give you the dot product of those two vectors in the real term, and the cross product in the imaginary term.

Anonymous 0 Comments

To answer it from a less utilitarian perspective, when constructing the numbers in math, the most popular model starts from defining the natural numbers (by constructing a set that adheres to the Peano axioms, but that’s not quite important now), and then doubling up the numbers, so an integer is represented by two naturals, so for example the integer 3 can be thought of as the natural 3 and the natural 0 in pair, where i3 is n3 – n0 in the common sense of subtraction. Any natural pairs where the difference is 3 will represent this integer. The same way we get to the rationals, just with “division”. The reals is a different jump, but after that we can continue doubling up, so we get the complex numbers, and from two complexes you get the quaternions, two quaternions give you octaves and so on.

The trick is, you always have to define how the usual operations, addition and multiplication works on pairs of numbers. It turns out you start to lose properties as you go higher than complex.