OnLine3-2-VisualLT3d.mws

Linear Algebra Powertool

Visualizing Linear Transformatio ns in R^3

OnLine 3.2

Worksheet by Michael K. May, S. J., revised by Russell Blyth

> restart: with(linalg): with(plots): with(plottools):

Warning, the protected names norm and trace have been redefined and unprotected

Warning, the name changecoords has been redefined

Warning, the name arrow has been redefined

Outline

This worksheet covers material similar to that covered in the On Line 3.2 section.

The basic objectives are:

Drawing a 3 dimensional car in Maple

We first need to get Maple to draw a 3 dimensional object. We follow the OnLine section in the student resource manual and work with the image of a car. We start by producing a two dimensional outline of a car.

> listcar := [[0,.0954], [.0102,.1612], [.1425,.2237], [.2124,.2336],
[.2513, .2401], [.2902, .2401], [.3187, .3158], [.3472, .3553],
[.3912, .3684], [.4611, .3750], [.5104, .3783], [.5674, .3783],
[.6373, .3783], [.6710, .3684], [.6891, .3520], [.7047, .3388],
[.7202, .3191], [.7306, .2961], [.7409, .2763], [.7876, .2664],
[.8135, .2599], [.8264, .2500], [.8394, .2368], [.8472, .2072],
[.8497, .1612], [.8497, .1513], [.8497, .1283], [.8497, .1020],
[.7350, .1020], [.7350, .0510], [.6840, .0000], [.6250, .0000],
[.5740, .0510], [.5740, .1020], [.3410, .1020], [.3410, .0510],
[.2900, .0000], [.2310, .0000], [.1800, .0510], [.1800, .1020],
[.0020, .1020]]:

We trace the outline.

> pointplot(listcar, style=line, view=[-0.2..1,0..0.5], axes=framed, scaling=constrained, color=black, labels=[x,z], labelfont=[TIMES, BOLD, 14]);

[Maple Plot]

To turn the car into a 3 dimensional object, we insert a y coordinate in between the x and z coordinates. We make the car .35 units wide, with the right side in the x-z plane.

> listcarright := map(u->[op(1,u), 0, op(2,u)],listcar):
listcarleft := map(u->[op(1,u), 0.35, op(2,u)],listcar):

Let's plot the two sides together, making the right side red and the left side blue. To plot the two sides with specified colors we use the display command. Note that the individual parts of the graph end with colons.

> rightside:= pointplot3d(listcarright, style=line, color=red):
leftside:= pointplot3d(listcarleft, style=line, color=blue):
display({rightside,leftside},axes=normal, scaling=constrained, orientation=[135,66]);

[Maple Plot]

To make it look like a single object we draw lines connecting the two sides of the car. We do that in green.

> listcarcross := [seq(op([listcarright[k],listcarleft[k]]),k=1..41)]:

> crossing:= pointplot3d(listcarcross, style=line, color=green):
display({leftside,rightside,crossing},axes=normal, scaling=constrained, orientation=[135,66]);

[Maple Plot]

Finally, we replace the axes with a garage. We will have transformations act on the car, while leaving the garage alone so that it can act as a reference frame.

> garage:=[[0,0,0], [1,0,0], [1,.35,0], [1,0,0], [1,0,.5], [1,.35,.5],
[1,0,.5], [0,0,.5], [0,.35,.5], [0,0,.5], [0,0,0], [0,.35,0],
[1,.35,0], [1,.35,.5], [0,.35,.5], [0,.35,0]]:
garagel:= pointplot3d(garage, style=line, color=black):
display({leftside,rightside,crossing,garagel}, axes=none, scaling=constrained, orientation=[135,66]);

[Maple Plot]

To reduce typing we define a function that turns a list of points into an outline of the desired color

> poly3d := (pointlist, shade) ->
pointplot3d(pointlist, style=line, color=shade):

This allows us plot the 4 lists together as follows.

> display(
{poly3d(listcarright,red), poly3d(listcarleft, blue),
poly3d(listcarcross, green), poly3d(garage, black)},
axes=none, scaling=constrained, orientation=[135,66]);

[Maple Plot]

We use the 4 lists in this example for the remainder of the worksheet.

Exercise:

1) To check that you understand the syntax of the commad, plot just the crossings of the car in orange together with the garage in green.

>

Visualizing Linear Transformations in R^3

In the previous OnLine section we looked at 2 by 2 matrices acting on R^2 . We are ready to extend this study to R^3 . We borrow a procedure that allows us to multiply a matrix by a list of vectors.

> multmatbylist := proc(multmat, listofvecs)
map(x->convert(evalm(multmat&*x),list),listofvecs);
end:

We start with a matrix that rotates objects by 90 degrees in the y-z plane (that is, around the x-axis). Such a transformation should send e1 to e1, e2 to e3, and e3 to -e2. We designate the matrix rot1.

> rot1:= matrix(3,3,[[1,0,0],[0,0,-1],[0,1,0]]);
testvec := [xcoord, ycoord, zcoord];
evalm(rot1&*testvec);

rot1 := matrix([[1, 0, 0], [0, 0, -1], [0, 1, 0]])

testvec := [xcoord, ycoord, zcoord]

vector([xcoord, -zcoord, ycoord])

Now we want to multiply the three carlists by rot1 and graph the result. Note that we leave the garage alone.

> rlist:=multmatbylist(rot1,listcarright):
llist:=multmatbylist(rot1,listcarleft):
clist:=multmatbylist(rot1,listcarcross):
display(
{poly3d(rlist,red), poly3d(llist, blue),
poly3d(clist, green), poly3d(garage, black)},
axes=none, scaling=constrained, orientation=[135,66]);

[Maple Plot]

We see that the transformation turns the car on its side.

As a second example, shear the car in the z direction by the value of x. (This jacks up the back end of the car.)

> shear1:= matrix(3,3,[[1,0,0],[0,1,0],[1,0,1]]);
rlist2:=multmatbylist(shear1,listcarright):
llist2:=multmatbylist(shear1,listcarleft):
clist2:=multmatbylist(shear1,listcarcross):
display(
{poly3d(rlist2,red), poly3d(llist2, blue),
poly3d(clist2, green), poly3d(garage, black)},
axes=none, scaling=constrained, orientation=[135,66]);

shear1 := matrix([[1, 0, 0], [0, 1, 0], [1, 0, 1]])...

[Maple Plot]

Exercises:

2) Use matrix multiplication to produce a single matrix that composes the rotation in the y-z plane followed by the shearing in the x-z plane (think carefully about the order of multiplication). Compare the result of multiplying this single matrix on the car with the result of first multiplying the car by the rotation matrix and then the result of the rotation by the shearing matrix.

>

>

3) Produce a matrix to rotate the figure counterclockwise 30 degrees about the x-axis and another matrix to rotate the image by 20 degrees counterclockwise about the z axis. Apply these matrices in succession to the image of the car and plot the result.

>

4) Obtain a single matrix that has the same effect as the composite of the two matrices in Exercise 3. Plot the result.

>

5) Write a hypothesis about the result of multiplying the image of the car by a rank 2 matrix. Create a random rank 2 matrix of size 3 by 3 and verify your hypothesis. (Your matrix should be of rank 2 with no zeros. Pay particular attention to what happens to the images of the sides of the car.)

>

6) Write a hypothesis about the result of multiplying the image of the car by a matrix with all zeros in the third column. Create a random 3 by 3 matrix of this type and verify your hypothesis. (Your matrix should be of rank 2 with zeros only in the third column. Pay particular attention to what happens to the images of the sides of the car. Your hypothesis should mention vectors that are in the null space.)

>

7) Write a hypothesis about the result of multiplying the image of the car by a rank 1 matrix. Create a random rank 1 matrix of size 3 by 3 and verify your hypothesis.

>

8) Write a hypothesis about the result of multiplying the image of the car by a matrix with all zeros in the first and third rows. Create a random 3 by 3 matrix of this type and verify your hypothesis. (Your hypothesis should mention interesting vectors in the image.)

>

>

>

>