Objective Learn how to rotate an image using rotation matrices.
In the Discovery Project Computer Graphics I we saw how matrix multiplication is used in computer graphics. We found matrices that reflect, expand, or shear an image. We now consider matrices that rotate an image, as in the graphics shown here.
Recall that a point $(x, y)$ in the plane is represented by the $2 \times 1$ matrix $\left[ \begin{array}{} x\\ y \end{array} \right]$. The matrix that rotates this point about the origin through an angle $ ɸ$ is $$R = \left[ \begin{array}{} \cos \; ɸ-\sin \; ɸ\\ \sin \; ɸ \;\;\; \cos \; ɸ \end{array} \right] \quad \color{#08F}{\textrm{Rotation} \; \textrm{matrix}}$$
Note that rotating a point counter-clockwise corresponds to rotating the axes clockwise.
When the point $P = \left[ \begin{array}{} x\\ y \end{array} \right]$ is rotated clockwise about the origin through an angle $ɸ$, it moves to a new location $P' = \left[ \begin{array}{} x'\\ y' \end{array} \right]$ given by the matrix product $P' = RP$, as shown in Figure 1.
$$P' = RP = \left[ \begin{array}{} \cos \; ɸ-\sin \; ɸ\\ \sin \;ɸ \;\;\; \cos \; ɸ \end{array} \right] \left[ \begin{array}{} x\\ y \end{array} \right] = \left[ \begin{array}{} x \; \cos \; ɸ - y \; \sin \; ɸ\\ x \; \sin \; ɸ + y \; \cos \; ɸ \end{array} \right]$$
For example, if $ɸ = 90^\circ$, the rotation matrix is $$R = \left[ \begin{array}{} \cos \; 90^\circ &-\sin \; 90^\circ\\ \sin \; 90^\circ & \;\;\; \cos \; 90^\circ \end{array} \right] = \left[ \begin{array}{} 0&-1 \\ 1& \;\;\; 0 \end{array} \right] \quad \color{#08F}{\textrm{Rotation} \; \textrm{matrix} \; (ɸ = 90^\circ)}$$
Applying a $90^\circ$ rotation to the point $P = \left[ \begin{array}{} 1 \\ 2 \end{array} \right]$ moves it to the point $$P' = RP = \left[ \begin{array}{} 0&-1 \\ 1& \;\;\; 0 \end{array} \right]\left[ \begin{array}{} 1 \\ 2 \end{array} \right] = \left[ \begin{array}{} -2 \\ \;\;\; 1 \end{array} \right]$$
See Figure 2.
If the rotation matrix is applied to every point in an image, then the entire image is rotated. To rotate the house in Figure 3(a) through a $30^\circ$ angle about the origin, we multiply its data matrix by the rotation matrix that has $ɸ = 30^\circ$.
$$RD = \left[ \begin{array}{} \frac{\sqrt 3}{2} & -\frac 12 \\ \frac 12 & \frac{\sqrt 3}{2} \end{array} \right] \left[ \begin{array}{} 2&0&0&2&4&4&3&3&2&2&3 \\ 0&0&3&5&3&0&0&2&2&0&0 \end{array} \right]$$ $$ \qquad \qquad \qquad \qquad \qquad \quad \approx \left[ \begin{array}{} 1.73&0&-1.50&-0.77&1.96&3.46&2.60&1.60&0.73&1.73&2.60 \\ \;\; 1&0& \;\;\; 2.60& \;\;\; 5.33&4.60& \;\; 2&1.50&3.23&2.73& \;\; 1&1.50 \end{array} \right]$$The new data matrix $RD$ represents the rotated house in Figure 3(b).
The Discovery Project: Computer Graphics II describes a TI-83 program that draws the image corresponding to a given data matrix. You may find it convenient to use this program in some of the following activities.
(a) $(1, 4), \; ɸ = 90^\circ$ | (b) $(-2, 1), \; ɸ = 60^\circ$ | |
(c) $(-2, -2), \; ɸ = 135^\circ$ | (d) $(7, 3), \; ɸ = -60^\circ$ |
$$(x, y) \leftrightarrow \left[ \begin{array}{cc|c} x \\ y \\ 1 \end{array} \right]$$
Reflection $\;$in $x$-axis |
Expansion (or $\;$ contraction) $\;$in $x$-direction |
$\;$Shear in $x$-direction |
Rotation about the $\qquad$origin by $\; \quad$the angle $ɸ$ |