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 . 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 matrix , we left-multiply this data matrix by (the effect is to multiply each column by and so transform each vertex).

For example, we can slant the letter to the right by multiplying by a horizontal shear matrix (See Formula form:shears.) The result is the letter with data matrix \begin{equation*} A = \left [ \begin{array}{ll} 1 & 0.2\\ 0 & 1 \end{array} \right ] \left [ \begin{array}{rrrrr} 0 & 6 & 5 & 1 & 3\\ 0 & 0 & 3 & 3 & 9 \end{array} \right ] = \left [ \begin{array}{lllll} 0 & 6 & 5.6 & 1.6 & 4.8\\ 0 & 0 & 3 & 3 & 9 \end{array} \right ] \end{equation*} which is shown in the figure below.

If we want to make this slanted matrix narrower, we can now apply a scaling matrix that shrinks the -coordinate by . (See Formula form:horvertscaling.) The result is the composite transformation \begin{align*} BAD &= \left [ \begin{array}{ll} 0.8 & 0\\ 0 & 1 \end{array} \right ] \left [ \begin{array}{ll} 1 & 0.2\\ 0 & 1 \end{array} \right ] \left [ \begin{array}{rrrrr} 0 & 6 & 5 & 1 & 3\\ 0 & 0 & 3 & 3 & 9 \end{array} \right ] \\ &= \left [ \begin{array}{lllll} 0 & 4.8 & 4.48 & 1.28 & 3.84\\ 0 & 0 & 3 & 3 & 9 \end{array} \right ] \end{align*}

which is drawn in the figure below.

On the other hand, we can rotate the letter about the origin through (or ) by multiplying by the rotation matrix (See Formula form:rotation.) This gives \begin{align*} R_{\frac{\pi }{2}} &= \left [ \begin{array}{ll} 0.866 & -0.5\\ 0.5 & 0.866 \end{array} \right ] \left [ \begin{array}{rrrrr} 0 & 6 & 5 & 1 & 3\\ 0 & 0 & 3 & 3 & 9 \end{array} \right ] \\ &= \left [ \begin{array}{lllrr} 0 & 5.196 & 2.83 & -0.634 & -1.902\\ 0 & 3 & 5.098 & 3.098 & 9.294 \end{array} \right ] \end{align*}

and is plotted in the figure below.

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 , that is apply the transformation given by for all in . The problem is that these translations are not matrix transformations because they do not carry to (unless ). (See Practice Problem prob:translation_does_not_work.) However, there is a clever way around this.

The idea is to represent a point as a column , called the homogeneous coordinates of . Then translation by can be achieved by multiplying by a matrix: \begin{equation*} \left [ \begin{array}{rrr} 1 & 0 & p\\ 0 & 1 & q\\ 0 & 0 & 1 \end{array} \right ] \left [ \begin{array}{r} x\\ y\\ 1 \end{array} \right ] = \left [ \begin{array}{c} x + p\\ y + q\\ 1 \end{array} \right ] = \left [ \begin{array}{c} T_{\vec{w}}(\vec{v})\\ 1 \end{array} \right ] \end{equation*} Thus, by using homogeneous coordinates we can implement the translation 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 is given by a matrix: \begin{equation*} \left [ \begin{array}{rrr} a & b & 0\\ c & d & 0\\ 0 & 0 & 1 \end{array} \right ] \left [ \begin{array}{r} x\\ y\\ 1 \end{array} \right ] = \left [ \begin{array}{c} ax + by\\ cx + dy\\ 1 \end{array} \right ] = \left [ \begin{array}{c} A\vec{v}\\ 1 \end{array} \right ] \end{equation*} So everything can be accomplished at the expense of using matrices and homogeneous coordinates.

It is interesting to examine the geometric implications of homogeneous coordinates. All points of the form , originally located in the -plane in , now have the form and are located in a horizontal plane in . What we perceive as a translation in the horizontal plane , is actually a shear in . This is similar to how horizontal shears in affect points along the line : all such points move a fixed distance to the left or to the right.

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 matrices are required.

Practice Problems

Consider the letter below.

Find the data matrix for the letter obtained by:

(a)
Rotating the letter through about the origin.
(b)
Rotating the letter through about the point .

Click the arrow to see the answer.

Find the matrix for reflecting in the line . Use as direction vector for the line.
Find the matrix for rotating through the angle about the point .
Find the reflection of the point in the line in if:
(a)
(b)

Click the arrow to see the answer.

(c)
What about ? Explain.
See Example exa:013322.
2024-09-11 17:54:35