Quaternion Rotation

# Arbitrary Axis Rotation

Previously we approached arbitrary axis rotation by viewing it as the composition of several major axis rotations. Now we will look at the rotation in a more straightforward fashion. When a point rotates about an axis, that point will travel in a circle. That circle lies in some plane. Therefore, if we could describe the plane of rotation we could describe our rotation as a 2D rotation in this plane. This will allow us to leverage the 2D matrix rotation that we have already developed.

## Vector Representation

To begin with, say we want to rotate by an angle of $\theta$ about an axis that passes through the origin and is parallel to the unit vector $\vec{v}$. We will define the vector $\vec{p}$ to be the vector that in standard position points to the point to be rotated $P$.

Notice that the path of the point $P$ as it revolves about the axis is a circle. We would like to describe a coordinate system for the plane that this path lies in. More specifically, we would like to define a $\vec{i}^*$ and $\vec{j}^*$ that will be the standard unit normals in this plane. These will serve the same roll as the standard unit normals $\vec{i}$ and $\vec{j}$ in the xy-plane. We can leverage our vector operations to create these new unit normals.
First we will define $\vec{i}^*$, to be the unit normal that points from the center of our rotation towards our point $P$.

Therefore this vector is in the direction of the perpendicular projection of $\vec{p}$ onto $\vec{v}$, but with unit length.

(1)
\begin{align} \vec{i}^*=\frac{\perp \mbox{Proj}_{\vec{v}}\vec{p}}{|\perp \mbox{Proj}_{\vec{v}}\vec{p}|} \end{align}

We would like $\vec{j}^*$ to be a unit vector perpendicular to both $\vec{i}^*$ and $\vec{v}$, so we can use the cross product of those two vectors. We just need to be careful to choose the order such that the rotation ends up following the right-hand rule.

(2)
\begin{align} \vec{j}^* = \vec{v} \times \vec{i}^* \end{align}

Note that since both $\vec{i}^*$ and $\vec{v}$ are unit vectors, their cross product is already a unit vector and requires no scaling.
So looking down our axis of rotation toward the origin, we would have the following picture.

In this new rotation space our point $P$ could be represented by the vector $\left < |\mbox{Proj}_\vec{v}\vec{p}|,0 \right >$ . Now we use our 2D rotation matrix to rotate this point in the rotation plane.

(3)
\begin{align} \left [ \begin{array}{cc} \cos \theta & -\sin \theta\\ \sin \theta & \cos \theta \end{array} \right ] \left [ \begin{array}{c} | \perp \mbox{Proj}_\vec{v} \vec{p} | \\ 0 \end{array} \right ] = \left [ \begin{array}{c} (\cos \theta ) | \perp \mbox{Proj}_\vec{v} \vec{p} | \\ (\sin \theta ) \perp \mbox{Proj}_\vec{v} \vec{p} | \end{array} \right ] \end{align}

So what we have here is the representation of our new point in the rotation plane in terms of $\vec{i}^*$ and $\vec{j}^*$. Now we need to express this in terms of our standard $\vec{i}$, $\vec{j}$, and $\vec{k}$ of the 3D space. So we would need to travel from the origin along the rotation axis to the origin of our rotation plane and then follow our rotated vector in the rotation plane.

(4)
\begin{align} \left | \mbox{Proj}_\vec{v} \vec{p} \right | \vec{v} + \left ( \cos \theta \right ) \left ( \left | \perp \mbox{Proj}_\vec{v} \vec{p} \right | \right ) \vec{i}^* + \left ( \sin \theta \right ) \left ( \left | \perp \mbox{Proj}_\vec{v} \vec{p} \right | \right ) \vec{j}^* \end{align}
(5)
\begin{align} =\left | \mbox{Proj}_\vec{v} \vec{p} \right | \vec{v} + \left ( \cos \theta \right ) \left ( \left | \perp \mbox{Proj}_\vec{v} \vec{p} \right | \right ) \frac{\perp \mbox{Proj}_\vec{v} \vec{p}}{\left | \perp \mbox{Proj}_\vec{v} \vec{p} \right |}+ \left ( \sin \theta \right ) \left ( \left | \perp \mbox{Proj}_\vec{v} \vec{p} \right | \right ) \left ( \vec{v} \times \frac{\perp \mbox{Proj}_\vec{v} \vec{p}}{\left | \perp \mbox{Proj}_\vec{v} \vec{p} \right |} \right ) \end{align}
(6)
\begin{align} =\left | \mbox{Proj}_\vec{v} \vec{p} \right | \vec{v} + \left ( \cos \theta \right ) \left ( \left | \perp \mbox{Proj}_\vec{v} \vec{p} \right | \right ) \frac{\perp \mbox{Proj}_\vec{v} \vec{p}}{\left | \perp \mbox{Proj}_\vec{v} \vec{p} \right |}+ \left ( \sin \theta \right ) \left ( \left | \perp \mbox{Proj}_\vec{v} \vec{p} \right | \right ) \left ( \vec{v} \times \frac{\perp \mbox{Proj}_\vec{v} \vec{p}}{\left | \perp \mbox{Proj}_\vec{v} \vec{p} \right |} \right ) \end{align}
(7)
\begin{align} =\left | \vec{p} \cdot \vec{v} \right | \vec{v} + \left ( \cos \theta \right ) \left ( \vec{p} - \mbox{Proj}_\vec{v}\vec{p} \right ) + \left ( \sin \theta \right ) \left ( \vec{v} \times \left ( \vec{p}-\mbox{Proj}_\vec{v}\vec{p} \right ) \right ) \end{align}

## Quaternion Representation

The vector operations we used in the above development can be written as a pair of quaternion multiplications.
If we want to rotate a point $P$ represented by the vector $\vec{p}$. about the line through the origin parallel to the unit vector $\vec{v}$ by an angle of $\theta$, our new vector $\vec{p_r}$ would be,

(8)
\begin{align} [0,\vec{p_r}]=qpq^{-1} \end{align}

where $q=[\cos \frac{\theta}{2},\vec{v}\sin \frac{\theta}{2}]$ and $p=[0,\vec{p}]$
Notice that our rotator quaternion $q$ has the special property that it is a unit quaternion, therefore

(9)
\begin{align} q^{-1}=\frac{q^*}{|q|^2}=\frac{q^*}{\cos^2 \frac{\theta}{2}+sin^2 \frac{\theta}{2}|\vec{v}|^2}=\frac{q^*}{\cos^2 \frac{\theta}{2} + \sin^2 \frac{\theta}{2}} = \frac{q^*}{1}=q^* \end{align}

Exercise
Use quaternion multiplication to rotate the point $(0,2,0)$ about the axis through the origin parallel to $\left < 1,1,1 \right >$ by an angle of $90^\circ$ according to the right hand rule.

# SLERP

Linear Interpolation (LERP) gives us a constant velocity parametrization of the path of least distance between two points. This path of shortest distance is a line segent. In 3D, when restricted to the surface of a sphere, the shortest distance between two points is a great arc. A great arc is a portion of a great circle which is a circle lying on the sphere that shares its center with the sphere. In geometry on a given surface the shortest distance between two points is referred to as a geodesic.
A Spherical Interpolation (SLERP) is a constant velocity parametrization of the path of least distance between two points when restricted to the surface of a sphere. What we will attempt to do now is find this parametrization. (Under Construction)

# Exercises

1. Explain what $\vec{i}^*$ and $\vec{j}^*$ represent in our arbitrary axis rotation.
2. How is the direction of rotation determined in our arbitrary axis rotation?
3. Under what conditions do the two quaternions $q^{-1}$ and $q^*$ equal one another?
4. What would the rotator quaternion be in rotating by $45^\circ$ about the axis parallel to $\vec{v}= \left < 2,1,3 \right >$ by the right hand rule?
5. Use quaternion multiplication to rotate the point $(2,0,0)$ about the axis parallel to $\vec{v}= \left < 0,5,0 \right >$ by $90^\circ$ according to the right hand rule.
6. Use quaternion multiplication to rotate the point $(3,-1,4)$ about the axis parallel to $\vec{v}= \left < 2,1,3 \right >$ by $45^\circ$ according to the right hand rule.
page revision: 140, last edited: 20 Nov 2017 19:24