### Multiplication Is Rotation

Solomon [7] introduces the multiplication map (p) = qpq* on showing it to be a linear map taking pure quaternions to pure quaternions with the neat composition property = . Now if n = (a, b, c) is a unit vector in and nq = (0, a, b, c), then = cos()h + sin()nq is a quaternion of unit magnitude for any angle t. Then becomes a rotation through angle t on with axis n. Julstrom [8] shows the equivalence of the matrix approach to the multiplication map based on the function M. Note that for a unit quaternion, the conjugate is the inverse. The operations will be incorporated in the function `Rotate[`vec`,` angle`,` axis`]` that takes a vector vec about an axis axis a given number of degrees angle.

Let us rotate the vector (1, 1, 1) 45 degrees about the x-axis represented by (1, 0, 0).

Thus the vector (1, 1, 1) when rotated about the x-axis has new position (1, 0, 1.41421). Now look at another example. Rotate (3, 4, 5) 50 degrees about the axis determined by the nonunit vector (2, -1, 1).

So, (3, 4, 5) rotates to (-0.0527686, -0.0347517, 7.07079).

Next we illustrate the very important fact that any sequence of rotations about various axes through the origin is equivalent to a single rotation about a single axis intersecting the origin. In fact, if = cos()h + sin()nq and = cos()h + sin()mq represent two rotations then = = so we can recover the composite angle and axis from the product of two quaternions. To illustrate take the vector (5, 7, 9) first rotated by 25 degrees about axis (1, .5, 1) and then 15 degrees about (.5, 0, 1)

So the vector (5, 7, 9) terminates at (3.27799, 5.27079, 10.7923). Next do the rotations in the reverse order and see what difference that makes.

Now (5, 7, 9) terminates at (3.18801, 4.76137, 11.0529). So the order matters!

We can illustrate the multiplicative property of the mapping M by looking directly at the quaternions that represent the two rotations above.

Now the amazing fact is that we can easily extract the axis and the angle from a quaternion that represents a rotation. The first component of the rotation is the cosine of half of the angle of rotation while the remaining three components give the axis though not necessarily as a unit vector. The latter is easily normalized. So using the example above, we can determine what the angle of t is as well as the unit axis.

Thus the single angle that accomplishes r and s above is 38.9884 degrees about the axis (.574224, .239584, .782858). We verify this next.

Next let us do a 90 degree rotation about the x-axis followed by a 90 degree rotation about the z-axis and ask what single rotation accomplishes this sequence.

So we see the sequence of these 90 degree rotations is equivalent to a 120 degree rotation about (1, 1, 1), which has been normalized to (.57735, .57735, .57735). As a last illustration here, let us find the result of a 180 degree rotation about the x-axis followed by a 120 degree rotation about (1, 1, -1) followed by a 90 degree rotation about (0, 1, 0).

The result is a 180 degree rotation about (0, 1, 1).

Finally, what if we want to rotate a vector about an axis that does not pass through the origin? The geometry of the situation is clear. Translate the axis to the origin, do the rotation, and then translate back. Let p denote an axis and v a vector that is to be rotated through an angle t about p. The v rotates to r(v-p) + p where r is the rotation through angle t. Let us rotate v = (1, 1, 1) through 45 degrees about an axis parallel to the x-axis but passing through p = (0, 2, 2).

Thus (1, 1, 1) has final resting position (1, 2, .585786).

For more on this fascinating topic confer Kuipers [9]