Math 291: Intro to Mathematica (for Linear Algebra)

with dusty wilson, mathematics instructor, highline community college
week 3

Contents

- Transformations in (ℝ^2)
- Transformations in (ℝ^3)

Initialization Cells

$Post:=If[MatrixQ[#],MatrixForm[#],#]&

L:={Table[{4Cos[m],2Sin[m]},{m,π,2π,(π/12)}],Table[{m,0},{m,-6,6,.3}],Table[{6,y},{y,0,.3,.01}],Table[{-6,y},{y,0,.3,.01}],Table[{.5Cos[m]-2,.25Sin[m]-.5},{m,0,2π,(π/12)}],Table[{.5Cos[m]+2,.25Sin[m]-.5},{m,0,2π,(π/12)}],Table[{.5Cos[m],.25Sin[m]-1},{m,((5π)/4),((7π)/4),(π/12)}],Table[{.5Cos[m]-2,.25Sin[m]-.75},{m,(π/4),((3π)/4),(π/12)}],Table[{.5Cos[m]+2,.25Sin[m]-.75},{m,(π/4),((3π)/4),(π/12)}],Table[{.5Cos[m]+.3,.4Sin[m]-1.5},{m,π,2π,(π/12)}],Table[{2Cos[m],.25Sin[m]-1.2},{m,((5π)/4),((7π)/4),(π/15)}],Table[{m,.3},{m,4,6,.2}],Table[{m,.3},{m,-6,-4,.2}],Table[{-4,y},{y,.3,1.5,.2}],Table[{4,y},{y,.3,1.5,.2}],Table[{m,1.5},{m,-4,4,.2}]}

M:={Table[{-4,y},{y,-1,1,.2}],Table[{4,y},{y,-1,1,.2}],Table[{6,y},{y,-1,1,.2}],Table[{-6,y},{y,-1,1,.2}],Table[{m,0},{m,4,6,.2}],Table[{m,0},{m,-6,-4,.2}],Table[{1.5Cos[m],Sin[m]+3},{m,0,2π,(π/12)}],Table[{m,(3/5)m+3},{m,-3.9,-1.1,.01}],Table[{m,((-3)/5)m+3},{m,1.1,3.9,.01}],Table[{m,3.5},{m,2,2,.1}],Table[{m,3.8},{m,1.5,1.5,.1}],Table[{m,3.5},{m,-2,-2,.1}],Table[{m,3.8},{m,-1.5,-1.5,.1}]}

data1:=Flatten[Table[Table[(4Pi-t){Cos[t+s Pi/2],Sin[t+s Pi/2],0}+{0,0,2t},{t,0,4Pi,.1}],{s,3}],1];

Transformation Matrices in 2D

scale2D[c_]:={{c,0},{0,c}}  (*scaling matrix - no shear*)
shear2D[a_,b_]:={{a,0},{0,b}} (*shear matrix - in the x direction*)
rotate2D[θ_]:={{Cos[θ],-Sin[θ]},{Sin[θ],Cos[θ]}} (*2D rotation matrix*)

Manipulate[ListPlot[Flatten[M,1].rotate2D[θ],Axes->False,Joined->False,PlotRange->7,AspectRatio->1],{{θ,0,"rotate θ"},-2π,2π}]

Manipulate[ListPlot[Flatten[L,1].scale2D[c],Axes->False,Joined->False,PlotRange->19,AspectRatio->1],{{c,1,"scale by c"},0,3}]

Manipulate[ListPlot[Flatten[L,1].shear2D[a,b],Axes->False,Joined->False,PlotRange->19,AspectRatio->1],{{a,1,"x-component"},0,3},{{b,1,"y-component"},0,3}]

Manipulate[ListPlot[Flatten[L,1].rotate2D[θ].scale2D[c].shear2D[a,b],Axes->False,Joined->False,PlotRange->7,AspectRatio->1,PlotLabel->rotate2D[θ].scale2D[c].shear2D[a,b]],{{θ,0,"rotate θ"},-2π,2π},{{c,1,"scale by c"},0,3},{{a,1,"x-component"},0,3},{{b,1,"y-component"},0,3}]

Transformations in 3D

(*text rotation matrix*)
m[θ_,ϕ_,φ_]:=RotationMatrix[θ,{1,0,0}].RotationMatrix[ϕ,{0,1,0}].RotationMatrix[φ,{0,0,1}]

faces=ExampleData[{"Geometry3D","SpaceShuttle"},"PolygonData"];
vertices=N@ExampleData[{"Geometry3D","SpaceShuttle"},"VertexData"];
Manipulate[
Graphics3D[
{EdgeForm[],GraphicsComplex[Table[m[θ,ϕ,φ].v,{v,vertices}],Polygon[faces]]},PlotRange->8],{θ,0,2π},{ϕ,0,2π},{φ,0,2π}]

(*my rotation matrix ... something is wrong*)
rotate3D[θ_,ϕ_]:={{Cos[ϕ] Cos[θ],Cos[ϕ] Sin[θ],Sin[ϕ]},{-Cos[ϕ] Sin[θ],Cos[ϕ] Cos[θ],Sin[ϕ]},{Sin[ϕ] Cos[θ],Sin[ϕ] Sin[θ],Cos[ϕ]}}
Manipulate[Graphics3D[
{EdgeForm[],GraphicsComplex[Table[rotate3D[θ,ϕ].v,{v,vertices}],Polygon[faces]]},PlotRange->8],{θ,0,2π},{{ϕ,0},((-π)/2),(π/2)}]

Simplify[Det[rotate3D[x,y]]]