Rotate With Dots

How to 3D

Chapter 4: Transformation Machinery

Rotate With Dots

Recall that 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}$$

A scale operation written with dot products feels clumsy with its zeroes cancelling out the unused components of \(\mathbf{p}\). Not so with rotation. The equations for \(p'_x\) and \(p'_y\) actually look like dot products: they multiply and sum the components of \(\mathbf{p}\).

As with scaling, let's rewrite the equations for rotation to use dot products, with the second vector again as \(\mathbf{p}\):

$$\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\) in that equation, so it must be zeroed out. Vector \(\mathbf{b}\) is derived similarly. That give us these two dot products:

$$\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; there is no multiplication and no summing. Nonetheless, it can be written as a dot product. The x- and y-components are zeroed out, and \(p_z\) stays the same, which means its coefficient in the first vector 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. All the remains is translation, which surely can be expressed as dot products. Right?

← Scale with DotsTranslate with Dots →