You are about to erase your work on this activity. Are you sure you want to do this?
Updated Version Available
There is an updated version of this activity. If you update to the most recent version of this activity, then your current progress on this activity will be erased. Regardless, your record of completion will remain. How would you like to proceed?
Mathematical Expression Editor
Application to Computer Graphics
Computer graphics deals with images displayed on a computer screen, and so arises
in a variety of applications, ranging from word processors, to Star Wars animations,
to video games, to wire-frame images of an airplane. These images consist of a
number of points on the screen, together with instructions on how to fill in areas
bounded by lines and curves. Often curves are approximated by a set of
short straight-line segments, so that the curve is specified by a series of
points on the screen at the end of these segments. Matrix transformations are
important here because matrix images of straight line segments are again line
segments.
Note that a color image requires that three images are sent, one to each of the red,
green, and blue phosphorus dots on the screen, in varying intensities.
Consider displaying the letter \(A\). In reality, it is depicted on the screen, as in the
figure below, by specifying the coordinates of the 11 corners and filling in the
interior.
For simplicity, we will disregard the thickness of the letter, so we require only five
coordinates as in the figure below.
This simplified letter can then be stored as a data matrix
where the columns are the coordinates of the vertices. Then if we want to transform
the letter by a \(2 \times 2\) matrix \(A\), we left-multiply this data matrix by \(A\) (the effect is to
multiply each column by \(A\) and so transform each vertex).
For example, we can slant the letter to the right by multiplying by a horizontal shear
matrix \(A = \left [ \begin{array}{ll} 1 & 0.2\\ 0 & 1\\ \end{array} \right ]\) (See Formula form:shears.) The result is the letter with data matrix
If we want to make this slanted matrix narrower, we can now apply a scaling matrix \(B = \left [ \begin{array}{ll} 0.8 & 0\\ 0 & 1 \end{array} \right ]\)
that shrinks the \(x\)-coordinate by \(0.8\). (See Formula form:horvertscaling.) The result is the composite
transformation
This poses a problem: How do we rotate about a point other than the origin? It turns
out that we can do this when we have solved another more basic problem. It is clearly
important to be able to translate a screen image by a fixed vector \(\vec {w}\), that is
apply the transformation \(T_{w} : \RR ^2 \to \RR ^2\) given by \(T_{w}(\vec {v}) = \vec {v} + \vec {w}\) for all \(\vec {v}\) in \(\RR ^2\). The problem is that these
translations are not matrix transformations \(\RR ^2 \to \RR ^2\) because they do not carry \(\vec {0}\) to \(\vec {0}\)
(unless \(\vec {w} = \vec {0}\)). (See Practice Problem prob:translation_does_not_work.) However, there is a clever way around
this.
The idea is to represent a point \(\vec {v} = \left [ \begin{array}{r} x\\ y \end{array} \right ]\) as a \(3 \times 1\) column \(\left [ \begin{array}{r} x\\ y\\ 1 \end{array} \right ]\), called the homogeneous coordinates of
\(\vec {v}\). Then translation by \(\vec {w} = \left [ \begin{array}{r} p\\ q \end{array} \right ]\) can be achieved by multiplying by a \(3 \times 3\) matrix:
Thus, by using
homogeneous coordinates we can implement the translation \(T_{w}\) in the top two
coordinates. At the same time, matrix transformations we performed earlier
can still be accomplished using homogeneous coordinates. For instance, the
matrix transformation induced by \(A = \left [ \begin{array}{rr} a & b\\ c & d \end{array} \right ]\) is given by a \(3 \times 3\) matrix:
So everything
can be accomplished at the expense of using \(3 \times 3\) matrices and homogeneous
coordinates.
It is interesting to examine the geometric implications of homogeneous coordinates.
All points of the form \(\begin{bmatrix}x\\y\end{bmatrix}\), originally located in the \(xy\)-plane in \(\RR ^2\), now have the form \(\begin{bmatrix}x\\y\\1\end{bmatrix}\) and
are located in a horizontal plane \(z=1\) in \(\RR ^3\). What we perceive as a translation in the
horizontal plane \(z=1\), is actually a shear in \(\RR ^3\). This is similar to how horizontal shears in \(\RR ^2\)
affect points along the line \(y=1\): all such points move a fixed distance to the left or to the
right.
Rotate the letter \(A\) through \(\frac {\pi }{6}\) about the point \(\left [ \begin{array}{c} 4\\ 5 \end{array} \right ]\).
Using homogenous coordinates for the vertices of the letter results in a data matrix
with three rows:
If we write \(\vec {w} = \left [ \begin{array}{c} 4\\ 5 \end{array} \right ]\), the idea is to use a composite of transformations: First translate the
letter by \(-\vec {w}\) so that the point \(\vec {w}\) moves to the origin, then rotate this translated letter,
and then translate it by \(\vec {w}\) back to its original position. The following GeoGebra
interactive illustrates this sequence.
The matrix arithmetic is as follows (remember the order of composition!):
This discussion merely touches the surface of computer graphics, and the reader is
referred to specialized books on the subject. Realistic graphic rendering requires an
enormous number of matrix calculations. In fact, matrix multiplication algorithms
are now embedded in microchip circuits, and can perform over 100 million matrix
multiplications per second. This is particularly important in the field of
three-dimensional graphics where the homogeneous coordinates have four
components and \(4 \times 4\) matrices are required.
Practice Problems
Consider the letter \(A\) below.
Find the data matrix for the letter obtained by:
(a)
Rotating the letter through \(\frac {\pi }{4}\) about the origin.
(b)
Rotating the letter through \(\frac {\pi }{4}\) about the point \(\left [ \begin{array}{c} 1\\ 2 \end{array} \right ]\).
Find the \(3 \times 3\) matrix for reflecting in the line \(y = mx + b\). Use \(\left [ \begin{array}{c} 1\\ m \end{array} \right ]\) as direction vector for the line.
Find the \(3 \times 3\) matrix for rotating through the angle \(\theta \) about the point \(P(a, b)\).
Find the reflection of the point \(P\) in the line \(y = 1 + 2x\) in \(\RR ^2\) if: