Illustrating linear transformations
Math 221 Linear Algebra, Fall 2021
September 14, 2021

T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

Description

This is a procedure that shows the effect of a linear transformation T:(ℝ^2)⟶ (ℝ^2) defined by T(x)=Ax where A is a 2x2 matrix.  

LT[A, set_of_pts] shows the effect of the transformation T on the polygon defined by set_of_pts. 

There are several predefined polygons:
	square1, square2, square3, triangle1, triangle2, pentagon1
For example, LT[ { {0,1},{1,0}}, square1]  will show the impact of the transformation defined by A=(({{0, 1}, {1, 0}}))  on square1.  square1 will be drawn in blue and T(square1) will be drawn in red.

The Mathematica procedure LT[ ] to display the effect of T

Don’t worry about the details of the code in this section. 
You can just use the LT[ ] function and pre-defined polygons as a black box. 
Notice that you’ll need to execute the input block below in order to use the procedure.

LT[A_,pts_] := Module[ { pts2,prange,i,diffpt,mainplot,ptscircle,pts2circle},
	
	pts2 = Transpose[ A.Transpose[pts]];
	prange = Max[ {Abs[pts],Abs[pts2]}]+0.5;
	diffpt = 1;
	While[ diffpt<Length[pts] && pts[[diffpt]]==pts2[[diffpt]], diffpt++];

mainplot=ListLinePlot[{pts, pts2}, AspectRatio->1,  PlotRange->{{-prange,prange},{-prange,prange}}, PlotStyle->{Blue, Red}, PlotMarkers -> "●",PlotLegends->{"Original", "T(original)"}];

ptscircle=Graphics[{Blue,Thick,Dashed,Circle[pts[[diffpt]],prange*0.1]}];
pts2circle=Graphics[{Red,Thick,Dashed,Circle[pts2[[diffpt]],prange*0.1]}];

Show[mainplot,ptscircle,pts2circle]
	
]

square1 = { {0,0}, {1,0}, {1,1}, {0,1}, {0,0}};
square2 = { {-0.5,-0.5},{0.5,-0.5},{0.5,0.5},{-0.5,0.5},{-0.5,-0.5}};
square3 = { {1,1},{2,1},{2,2},{1,2},{1,1}};
triangle1 = { {0,0},{1,0},{Cos[Pi/3],Sin[Pi/3]},{0,0}};
triangle2 = { {1,0},{2,0},{Cos[Pi/3]+1,Sin[Pi/3]},{1,0}};
rm={ {Cos[2Pi/5],-Sin[2Pi/5]},{Sin[2Pi/5],Cos[2Pi/5]}};pentagon1 = { {0,1}, rm.{0,1}, rm.rm.{0,1},rm.rm.rm.{0,1},rm.rm.rm.rm.{0,1},{0,1}};

Examples of using the procedure

You can use these as templates for your own transformations.

LT[ {{0,-1},{1,0}}, square1]

LT[ {{0,-1},{1,0}}, square2]

LT[ {{0,-1},{1,0}}, triangle1]

LT[ {{0,-1},{1,0}}, triangle2]

LT[{{0,-1},{1,0}}, pentagon1]