The Journal of Online Mathematics and Its Applications, Volume 7 (2007)
Experiments with Matrices and Vectors in Calculus and Linear Algebra, Sulewski, Kobylski, and Wattenberg

The Mathematics of Animations

This OSSLET is used in the first course of our four semester core mathematics sequence. The course has a three week block of instruction on matrix operations and solutions to systems of equations that culminates with two 55 minute lessons: Image Transformations I (Manipulating Still Images) and Image Transformations II (Animations).

The system of equations used in this exercise is written in matrix vector notation:

\underbrace{\vec y}_{\rm location \ on \ the \ screen} = \ \ A \underbrace{\vec x}_{\rm point \ in \ original \ image} + \ \ \vec b \quad \quad {\rm or} \quad \quad \left[{\begin{array}{c}y_1 \\ y_2 \\ \end{array}}\right] = \left[{\begin{array}{cc}a_{11} & a_{12} \\ a_{21} & a_{22} \\ \end{array}}\right] \left[{\begin{array}{c}x_1 \\ x_2 \\ \end{array}}\right] + \left[{\begin{array}{c} b_1 \\ b_2 \\ \end{array}}\right] \quad \quad {\rm or} \quad \quad \begin{eqnarray} y_1 &=& a_{11} x_1 + a_{12} x_2 \\ y_2 &=& a_{21} x_1 + a_{22} x_2 \\ \end{eqnarray}

Students use the imageAnimations OSSLET to see a visual effect. Then they must find a matrix A and a vector \vec b that will produce this effect. Finally, they use the OSSLET to check their work.

Open the OSSLET with an extra twist. We have marked three points in the original image, the points located at (0, 0) (marked by a red square), (1, 0) (marked by a green square), and (0, 1) (marked by a blue square). Try the various animations to see what happens to these three points during the animations.

Notice that

A\left[{\begin{array}{c}0 \\ 0 \\ \end{array}}\right] + \vec b = \vec b

so that the vector \vec b determines what happens to the point (0, 0) (marked by a red square).

In addition, notice that

\left[{\begin{array}{cc} a_{11} & a_{12} \\ a_{21} & a_{22} \\ \end{array}}\right] \left[{\begin{array}{c}1 \\ 0 \\ \end{array}}\right] = \left[{\begin{array}{c} a_{11} \\ a_{21} \\ \end{array}}\right] \quad \quad {\rm and} \quad \quad \left[{\begin{array}{cc} a_{11} & a_{12} \\ a_{21} & a_{22} \\ \end{array}}\right] \left[{\begin{array}{c} 0 \\ 1 \\ \end{array}}\right] = \left[{\begin{array}{c} a_{12} \\ a_{22} \\ \end{array}}\right].

Thus,

A \left[{\begin{array}{c}1 \\ 0 \\ \end{array}}\right] + \vec b = \left[{\begin{array}{c} a_{11} + b_1 \\ a_{21} + b_2 \\ \end{array}}\right] \quad \quad {\rm and} \quad \quad A \left[{\begin{array}{c}0 \\ 1 \\ \end{array}}\right] + \vec b = \left[{\begin{array}{c} a_{`12} + b_1 \\ a_{22} + b_2 \\ \end{array}}\right].

In particular if \vec b = (0, 0) then the point (1, 0) is placed at the location on the screen given by the first column of the matrix A and the point (0, 1) is placed at the location on the screen given by the second column of the matrix A.

It is often helpful to think of the transformation \vec y = A \vec x + \vec b as having two steps:

Notice that if the matrix A is the identity matrix then

A \vec x + \vec b = I \vec x + \vec b = \vec x + \vec b \quad \quad {\rm or} \quad \quad A \vec x + \vec b = \left[{\begin{array}{cc}1 & 0 \\ 0 & 1 \\ \end{array}}\right] \left[{\begin{array}{c} x_1 \\ x_2 \\ \end{array}}\right] + \left[{\begin{array}{c} b_1 \\ b_2 \end{array}}\right] = \left[{\begin{array}{c} x_1 + b_1 \\ x_2 + b_2 \\ \end{array}}\right]

and we have a pure translation with the original image sliding left or right by b_1 and up or down by b_2

Manipulating Still Images

Day one of this two-day lesson concentrates on placing a still image at a location on the screen by applying one of the following techniques: Scale the image to a different size; translate or shift the image; skew the image; reflect; and rotate the image about an axis. Most students will be able to discover how to accomplish most of these transformations.

Since we are manipulating still images rather than creating animations, the time parameter t does not appear in either the matrix A or the vector \vec b.

Creating Animations

The difference between an animation and simply manipulating a still image is time. For an animation the location on the screen of each point in the original image depends on time. Thus, the entries in the matrix A and the vector \vec b depend on the time parameter t. The OSSLET is designed so that this parameter starts at t = 0 and goes up to t = 1. As an example, consider the Jump Challenge in the OSSLET we have been using on this page. In that window click the Jump Challenge button and then the Play button. Notice the Black Knight jumps straight up with no scaling, rotation, or skewing. The matrix A is the identity matrix and the vector \vec b is responsible for the action we see. In this example,

\vec b = \left[{\begin{array}{c}b_1 \\ b_2 \\ \end{array}}\right] = \left[{\begin{array}{c} 0 \\ 12 t (1 - t)\\ \end{array}}\right]

Just as with transformations of still images, it is often helpful to think of an animation as having two components:

The Spinning in Place Challenge in the OSSLET is an example of an animation with \vec b(t) = 0 so that the Black Knight remains in the center of the screen but in this case as the time t goes from zero to one he rotates counterclockwise through two complete rotations. This animation is produced by

\vec y = \left[{\begin{array}{cc}\cos (4 \pi t) & -\sin(4 \pi t) \\ \sin(4 \pi t) & \cos (4 \pi t) \\ \end{array}}\right] \vec x + \left[{\begin{array}{c} 0 \\ 0 \\ \end{array}}\right].