Quaternions as Rotations
Let $p$ be a 3D point represented as a quaternion using its homogeneous coordinates, $p = [w, \mathbf{v}]$, and let $q$ be any non-zero quaternion. Then:
Theorem: The product $qpq^{-1}$ takes $p = [w, \mathbf{v}]$ to $p’ = [w, \mathbf{v’}]$.
Before proving this theorem, let’s make the following observation. We can express $q$ as a multiplication of a scalar quaternion $s$ and a unit quaternion $\mathbf{U}q$, so $q = s\mathbf{U}q$. Then $qpq^{-1}=s\mathbf{U}qp(s\mathbf{U}q)^{-1}=s\mathbf{U}qp\mathbf{U}q^{-1}s^{-1}$. Because the scalar multiplication is commutative, $\mathbf{U}qp\mathbf{U}q^{-1}ss^{-1}=\mathbf{U}qp\mathbf{U}q^{-1}$, so the product doesn’t change irrespective of whether $q$ is a unit quaternion or not. Finally, notice that $\mathbf{U}q^{-1} = \mathbf{U}q^*$, so we can write the action as $qpq^*$. Note that from now on, $q$ is assumed to be a unit quaternion without loss of generality.
Next, let’s prove that the scalar part of $qpq^{*}$ is the same as the scalar of $p$ (we can use the formula to find the scalar component of a quaternion):
Therefore, the scalar part of $p$ remains constant in the operation, i.e., if $p = [w, \mathbf{v}]$, then $p’ = qpq^{*} = [w, \mathbf{v’}]$. And because multiplication preserves norms, then $\norm{p} = \norm{p’}$ and also $\norm{v} = \norm{v’}$. $\blacksquare$
Theorem: If $\norm{q} = 1$, then $q = [\cos{\theta}, \unit{v} \sin{\theta}]$ acts to rotate around the unit axis $\unit{v}$ by $2 \theta$.
Let:
Be two pure quaternions (which can be represented in 3D space), and an arbitrary quaternion $q$ which has the form:
Let $\theta$ be the angle between $\mathbf{v_0}$ and $\mathbf{v_1}$. Then $\mathbf{v_0 \cdot v_1} = \cos{\theta}$. Also, let $\mathbf{v_0 \times v_1} = \sin{\theta} \unit{v}$. Then \eqref{q} becomes:
Let’s first prove that the product $v_2 = qv_0q^{*}$ lies in the same plane as $\mathbf{v_0}$ and $\mathbf{v_1}$. We do so by first proving that the product $v_2v_1^*$ has the same components (dot and cross products) as $v_1v_0^*$:
Then, if $v_2 v_1^* = v_1v_0^*$, that means that $v_2=qv_0q^*$ lies in the same plane as $v_0$ and $v_1$. Also, $v_2$ forms an angle of $\theta$ with $v_1$. Furthermore, $\mathbf{v_1} \times \mathbf{v_2} = \unit{v} \sin{\theta}$. Finally, if the angle between $v_0$ and $v_1$ is $\theta$, then the angle between $v_0$ and $v_2$ is $2\theta$, which confirms what’s seen on the image above.
Furthermore, the same can be said of $q$ acting on $v_1$. Let $v_3 = qv_1q^{*}$. Then:
Now, any vector $p$ can be represented in terms of the basis $v_0$, $v_1$, and $\unit{v}$, e.g., $p = s_1\mathbf{v_0} + s_1\mathbf{v_1} + s_2\unit{v}$. We’ve seen what $q$ does to $v_0$ and $v_1$, so let’s see what it does to $\unit{v}$.
Before computing $q\unit{v}q^{*}$, see that:
So $q\unit{v}$ is a commutative operation because the cross product is the only term that makes the quaternion operation non-commutable, and in $q\unit{v}$, that term is zero. Therefore, $q\unit{v}q^ * = \unit{v}qq^ * = \unit{v}$, which means that $q$ does not modify $\unit{v}$.
Thus, the action of $q$ on any vector $p$ is a rotation around $\unit{v}$ by $2\theta$. $\blacksquare$
Quaternion Rotation Facts
Let $q_1$ be a quaternion that rotates the pure quaternion $p_1$ to $p_2$, and also let $q_2$ be a quaternion that rotates the vector $p_2$ to $p_3$. Then $p_3$ will have the form:
Therefore, the combination of rotation $q_1$ followed by $q_2$ is given by $q = q_2q_1$.
When the rotations $q_1, q_2, \ldots, q_n$ are applied to the pure quaternion $p$, the result is equal to $qpq^*$, where $q = q_n q_{n-1} \ldots q_2 q_1$.