September 15, 2015

This is a simple 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 tranformation T on the polygon defined by set_of_pts. 

There are several predefined polygons:
	Square1, Square2, Square3, Triangle1, Triangle2, Pentagon
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.

Don’t worry about the details of the code in this section. 
You can just use the LT[ ] function and defined polygons as a black box.

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}};

These are a few examples of how to use the procedure.

LT[(({{0, -1}, {1, 0}})),Square1]

LT[(({{0, -1}, {1, 0}})),Square3]

LT[(({{0, -1}, {1, 0}})),Triangle1]

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

LT[(({{1/Sqrt[2], -1/Sqrt[2]}, {1/Sqrt[2], 1/Sqrt[2]}})),Pentagon1]

Here’s a template for you to enter your own matrices, and of course, play around with the different polygon options.

LT[(({{\[Placeholder], \[Placeholder]}, {\[Placeholder], \[Placeholder]}})), Square1]