## Rotation Matrix

There’s a book by D. F. Rogers and J. A. Adams called “Mathematical Elements for Computer Graphics”. It’s a wonderful book, but it changed enormously when it came out in second edition. The first edition was type-written; the second edition was typeset with dramatically changed contents.

One of the major changes from the first edition was in the treatment of general 3-dimensional rotation matrices. The earlier edition had a wonderful derivation, using direction cosines (related to the Euler angles) of an arbitrary axis and vector calculus. In the later edition, this was replaced by a more modern, and admittedly simpler, treatment using conjugation (a sort of product) of matrices.

As a result of this change, something was lost: an elegant and symmetrical representation of the general rotation matrix. Here it is, simplified slightly (I have ignored the use of homogeneous coördinates, and assumed the axis of rotation passes through the origin):

$\left[ \begin{array}{ccc} u^2+(1-u^2)c & uv(1-c)+ws & uw(1-c)-vs \\ uv(1-c)-ws & v^2+(1-v^2)c & vw(1-c)+us \\ uw(1-c)+vs & vw(1-c)-us & w^2+(1-w^2)c \end{array} \right]$

where:
$\langle u,v,w \rangle$ is a unit vector parallel to the axis of rotation,
$c=\cos (\vartheta)$ and
$s=\sin (\vartheta)$, where
$\vartheta$ is the angle of rotation.

Notice that $u^2+v^2+w^2 = 1$ and $c^2 + s^2 = 1$.

For convenient copy-and-paste here it is as text in a table, with exponentiation shown as (^) and multiplication as (*):

 u^2+(1-u^2)*c u*v*(1-c)+w*s u*w*(1-c)-v*s u*v*(1-c)-w*s v^2+(1-v^2)*c v*w*(1-c)+u*s u*w*(1-c)+v*s v*w*(1-c)-u*s w^2+(1-w^2)*c