Linear Transformations

Here is a module that visualizes a linear transformation. It accepts a 2×2 matrix A and draws the transformation defined T(x)=A x.

drawTransformation[matrix_]:=Module[
(* local variables *) 
{e1={1,0},e2={0,1},v1,v2},

(* compute the transformation *) 
v1=matrix.e1;
v2=matrix.e2;

(* create the graphics objects *)
originalVectorGraphic=Graphics[{Blue,Thick,Dashed,Arrow[{{0,0},e1}],Green,Arrow[{{0,0},e2}],Thin,Gray,Line[{{e1,{1,1},e2}}]}];
transformedVectorGraphic=Graphics[{LightBlue,Polygon[{{0,0},v1,v1+v2,v2}],Blue, Thick,Arrow[{{0,0},v1}],Green,Arrow[{{0,0},v2}]}];

(* combine and display the graphics *)
Show[transformedVectorGraphic,originalVectorGraphic,Axes->True,PlotRange->All]
]

Sample transformation

Here is a sample linear transformation that multiplies vectors by the following matrix.

A={{2,1},{1,3}};
MatrixForm[A]

Here is the visualization of the transformation. Note that the vectors (Subscript[e, 1]) and (Subscript[e, 2]) are drawn with dashed arrows, and the transformed vectors T((Subscript[e, 1])) and T((Subscript[e, 2])) are drawn with solid arrows. The image of the unit square [0,1]×[0,1] is also drawn.

drawTransformation[A]

Shear transformation

A shear transformation keeps one of the standard basis vectors fixed, while displacing the other standard basis vector. Here is an example of a shear transformation.

shear={{1,1},{0,1}};
MatrixForm[shear]

drawTransformation[shear]

Rotation transform

A rotation transformation rotates the plane while keeping the origin fixed. The following rotation transformation rotates by 45 degrees counterclockwise.

rotation={{((Sqrt[2])/2),((-(Sqrt[2]))/2)},{((Sqrt[2])/2),((Sqrt[2])/2)}};
MatrixForm[rotation]

drawTransformation[rotation]

Scaling transformation

A scaling transformation stretches or compresses the plane in each coordinate direction. Here is an example that stretches the horizontal axis by a factor of 3 while compressing the vertical axis by a factor of (1/2).

scale={{3,0},{0,0.5}};
MatrixForm[scale]

drawTransformation[scale]

Scaling transformation

A projection transformation maps a larger space onto a smaller space. For example, the following transformation maps the plane onto the horizontal axis.

proj={{1,0},{0,0}};
MatrixForm[proj]

drawTransformation[proj]