Quaternions are mathematical things that represent rotations in 3D. They can be used everywhere, where you need to rotate stuff, or keep track of rotations. Each quaternion represents a rotation. The inverse is not true, as there are many quaternions, that give the same rotation: `2q`, `3q`, `1.5q`, `-5q`, etc. are the same rotation as just `q`.
Quaternions are made of 4 basic components:
* “Do nothing”. Does not rotate anything. Represented by number `1`.
* 180 deg around X (in YZ plane). Represented by `i`.
* 180 deg around Y (in XZ plane). Represented by `j`.
* 180 deg around Z (in XY plane). Represented by `k`.
You can then add that components. When you add two components, you get an “in between” rotation. For ex., `i + j` is a 180 deg rotation “in between” XZ and YZ. The `1 + i` is “in between” 180 deg around X and do nothing – so it is 90 deg around X. `2 + i` is similar, but “do nothing” is twice as strong, so it is around 60-ish deg around X. By adding some portions of the bases you can get any rotation.
You can also multiply quaternions: `A*B` is a rotation, which you get by applying first `B`, and then `A`. Note, that `A*B` is not the same as `B*A`, because in 3D the order of rotations matter.
Latest Answers