## Visualizing 2-dimensinal Linear Transformations

The goal of this page is to help you understand how a 2 by 2 matrix defines a
transformation of the two-dimensional plane. The wikipedia page on
transformation matrices provides a good explanation of how this works.
Briefly, each point (x,y) in the plane gets moved to a new point T(x,y) by the
simple rule that T(x,y)=A**x**, where A is a 2x2 matrix, **x** is the
column vector with coordinates x and y, and we interpret the column vector that
results from the matrix multiplication as a new point in the plane. To help
visualize this, we can "transform" an image by moving the pixels by this rule
(keeping their color and brightness unchanged).
You should imagine that the image starts out in the first quadrant of the
plane with the origin at its lower left corner.
To use this page, just:

1) Pick an image. Either one of the two "built-in's" or anything else from
the web.

2) Adjust the entries of the matrix. It starts out as the identity
matrix, which won't change the image at all.

3) Click **[try it out]**

Transformed image:

Original image:

**Some suggestions** (i.e., for my students, *homework*)
1) Start with diagonal matrices, like

1.5 0.0
0.0 0.5

The above example will stretch the image in the horizontal direction and
shrink it vertically. Try putting negative numbers in one or both of the
diagonal entries, and explain what happens.
2) Try a matrix with zero's on the diagonal, like

0 1
1 0

The above example swaps the x and y axes, so it reflects the image around the
line y=x. You can combine this effect with stretching and shrinking, and you
can use negative values to change the reflection to a rotation through a right
angle. Be sure you understand what happens in each case, and why.
3) Try a rotation matrix, which has the form

cos(θ) -sin(θ)
sin(θ) cos(θ)

Pick an angle and get out your calculator to compute the matrix values.
Finally, you can use trigonometry for something entertaining!
4) Try more general examples. To predict and understand the effect, just
remember that the left matrix column is equal to T(1,0) and
tells where the x-axis goes; while the right
column equals T(0,1) and
tells where the y-axis goes. The rest of the image is just
pulled along "linearly". You can tell where a pixel will be by using vector
addition:

T(x,y) = x T(1,0) + y T(0,1)

5) Observe how the
determinant
of the matrix effects the transformed image. If you haven't already, try a
matrix whose determinant is zero. This will squash the image to a line (or
just a point), so the transformed image will be invisible! What happens when
the determinant is almost zero? What does a large determinat do? Note that
the total area of the transformed image will be equal to the area of the
original times the absolute value of the determinant. If the determinant is
negative, then the "orientation" of the image will be reversed. Text will be
hard to read, Tux's paintbrush will move from his left hand to his right.
Final note: if your transformed image is a red circle with an x in the middle,
it means the program couldn't find your image, or you gave it a matrix it
couldn't handle, or maybe you've found a bug in the software.

Please email comments or suggestions to jeff "at" math.tntech.edu.
The "heavy lifting" for this script is done by:
Graphics Magick.

The perl code for this page can be viewed: here