Rotate With Dots

In which you learn how rotation can be expressed in terms of dot products.

Writing scale as a dot product probably seemed a little backward. It took a very simple multiplication and turned it into something more complex. Hopefully rotation will seem more natural. Rotating point \(\mathbf{p}\) by \(a\) radians around the z-axis produces point \(\mathbf{p'}\) with the following components:

$$ \begin{aligned} p'_x &= \cos a \times p_x - \sin a \times p_y \\ p'_y &= \sin a \times p_x + \cos a \times p_y \\ p'_z &= p_z \end{aligned} $$

Unlike scaling, the definitions of \(p'_x\) and \(p'_y\) actually look like dot products. You are multiplying and summing the components of \(\mathbf{p}\).

As with scaling, you want to rewrite the equations above to use dot products. They will have this form:

$$ \begin{aligned} p'_x &= \mathbf{a} \cdot \mathbf{p} \\ p'_y &= \mathbf{b} \cdot \mathbf{p} \\ p'_z &= \mathbf{c} \cdot \mathbf{p} \end{aligned} $$

The first two components of \(\mathbf{a}\) are plucked right from the scalar definition of \(p'_x\). There's no mention of \(p_z\), so it must be zeroed out. Vector \(\mathbf{b}\) is derived similarly. You've got this much figured out:

$$ \begin{aligned} p'_x &= \begin{bmatrix}\cos a & -\sin a & 0\end{bmatrix} \cdot \mathbf{p} \\ p'_y &= \begin{bmatrix}\sin a & \cos a & 0\end{bmatrix} \cdot \mathbf{p} \\ \end{aligned} $$

The scalar definition of \(p'_z\) does not look like a dot product. Nonetheless, it can be written as one. The x- and y-components are zeroed out, and \(p_z\) stays the same, which means its coefficient in the dot product machinery must be 1:

$$ \begin{aligned} p'_z &= \begin{bmatrix}0 & 0 & 1\end{bmatrix} \cdot \mathbf{p} \end{aligned} $$

Altogether, a rotation around the z-axis has this dot product form:

$$ \begin{aligned} p'_x &= \begin{bmatrix}\cos a & -\sin a & 0\end{bmatrix} \cdot \mathbf{p} \\ p'_y &= \begin{bmatrix}\sin a & \cos a & 0\end{bmatrix} \cdot \mathbf{p} \\ p'_z &= \begin{bmatrix}0 & 0 & 1\end{bmatrix} \cdot \mathbf{p} \end{aligned} $$

Two transformations down, one to go. Can you make it work for translation?