Quaternions are most commonly used in ๐๏ธ Computer Vision or ๐ฆพ Robotics to compute 3D rotations. This is analogous to how multiplying by a complex number with unit magnitude rotates points in the complex plane.
Since a quaternion lies in 4D space, we canโt visualize its effect directly. However, we can see the unit quaternion in 3D via stereographic projection where the projection of is the intersection of a line through and with the imaginary hyperplane.
The function is a multiplication of a rotation quaternion with a unit quaternion . Each of the points is a key-point on the 4D unit hypersphere, and the two perpendicular circles are two chosen spheres on the hypersphere; note that the yellow line is still a circle, but one of its points is at infinity. Below is another visualization that transforms the yellow sphere so it can be projected as a circle instead of a line.
In this visualization, multiplying with a rotation rotates these two circles. For examples, if we let
moves to in the yellow circle, and moves to in the red circle, both completing 90-degree rotations. More generally, for multiplication with any quaternion that uses all four bases
our projected sphere both rotates and expands into a plane as our real component decreases.
More visualizations and further explanations can be found here thanks to Ben Eater and 3B1B.
To use quaternions for rotations, we usually want to isolate rotations and avoid the synced double-rotations observed above. Let
For the simple case where and , we observe that if we visualize and , the circle defined by and rotates in opposite directions while the other circle defined by and rotates in the same direction. Combining them together and noting that (since is unit), we arrive at the general rotation formula
These multiplications result in the former circleโs rotation cancelling out and the latter circleโs rotation compounding; visually, the first multiplication โbubblesโ the projected sphere outwards and the second multiplication โshrinksโ it back, but both are rotating the sphereโs equator perpendicular to the axis.
This property holds for any unit axis of rotation . Our function thus gives a general method for rotating around axes in 3D by negating the rotation in the extra fourth (real) dimension, and it can be implemented as simple quaternion multiplication following the rules above.