Linear Transformations with Mathematica

We'll define a figure by connecting the dots. First define the "dots" as a list of vectors in R^2. Just click on the following command (Shift-Enter). Nothing will appear yet.

house = {{-6,-7},{-6,2},{-7,1},{0,8},{7,1},{6,2},{6,-7},{-3,-7},{-3,-2},{0,-2},{0,-7},{-6,-7}};

Here are two funnctions will be using. The function LinTrans applies the linear transformation defined by the matrix matr to the set of vectors in x. The result is a set of vectors Ax. The function ShowPicture "connects the dots" and plots the image of the linear transformation. Again, just click, nothing will appear yet.

LinTrans[matr_,x_] :=Table[ matr.x[[i]],{i,1,Length[x]}]; ShowPicture[v_] := Show[Graphics[Line[v]], AspectRatio ->Automatic, Axes->True,PlotRange->10]

Manipulate[{  MatrixForm[{{a,b},{c,d}}],ShowPicture[Dot[{{a,b},{c,d}},#]&/@ house]},{{a,1},-3,3},{{b,0},-3,3},{{c,0},-3,3},{{d,1},-3,3}]

Rotations

Rotate 90 degrees counterclockwise

R = {{0,-1},{1,0}}; R // MatrixForm

ShowPicture[LinTrans[R,house]]

The general rotation matrix. Rotate z radians counterwise (we'll start off with z = - 45 degrees )

Clear[R]; R[z_] := {{ Cos[z],-Sin[z]},{Sin[z],Cos[z]}}; R[-Pi/4]//MatrixForm

ShowPicture[LinTrans[R[-Pi/4],house]]

Manipulate[{  MatrixForm[{{Cos[z],-Sin[z]},{Sin[z],Cos[z]}}],ShowPicture[Dot[{{Cos[z],-Sin[z]},{Sin[z],Cos[z]}},#]&/@ house]},{{z,0},-2Pi,Pi}]

Scalings

Manipulate[{  MatrixForm[{{a,0},{0,a}}],ShowPicture[Dot[{{a,0},{0,a}},#]&/@ house]},{{a,1},-3,3}]

Shears

Manipulate[{  MatrixForm[{{1,a},{0,1}}],ShowPicture[Dot[{{1,a},{0,1}},#]&/@ house]},{{a,1},-3,3}]

Projections

Manipulate[{  MatrixForm[{{a^2,a*b},{a*b,b^2}}],ShowPicture[Dot[{{a^2,a*b},{a*b,b^2}},#]&/@ house]},{{a,1},-3,3},{{b,1},-3,3}]

We'll see that this is a projection transformation. In this case, the transformation is a projection on the line spanned by [4 3]

Random Linear Transformations

A random linear transformation. The entries of the 2-x-2 matrix are picked uniformly at random from the interval [-1, 1].

B:={A=Table[RandomReal[{-1,1}],{i,1,2},{j,1,2}];ShowPicture[LinTrans[A,house]]}

B

B