Lab 7: Rotational Transforms Sample Solutions
As usual, reset things. But in this case we also want to load a couple of prebuilt Maple routines for linear algebra.
1. Identify the matrix for a rotation through angle φ about the positive z axis. Well, this is just the standard rotation matrix we have had in many places (example on p. 416) where we make sure to leave the z-axis unchanged:
| > |
R := matrix([[cos(phi),-sin(phi),0],[sin(phi),cos(phi),0],[0,0,1]]); |
2. Identify the 3×3 matrix for the transformation which brings the point (1,1,1) to the point (0,0,sqrt(3)) via a counterclockwise rotation about the line from the point (1,–1,0) to the origin (looking toward the origin). The rotation is through angle α, where cos (α) = 1/sqrt(3) . This is the same as rotating a line about the z-axis 45? counter-clockwise followed by some rotation about the x-axis. So first I write my matrix for rotating about the z-axis 45?:
| > |
M1 := matrix([[cos(Pi/4),-sin(Pi/4),0],[sin(Pi/4),cos(Pi/4),0],[0,0,1]]); |
| > |
test := vector ([1,1,1]); |
| > |
test_rot := evalm(M1 &* test); |
Now I have to figure out how much I have to rotate by to get this rotated vector onto the z-axis, I can use a dot product (since A•B = ABcos(theta) ==> theta = arccos(A•B/AB) ) to figure out the angle between this and the "final" vector we want:
| > |
final := vector ([0,0,sqrt(3)]); |
| > |
theta := arccos(dotprod(test_rot, final) / dotprod(final,final)); cos_angle := cos(theta); sin_angle := sin(theta); |
So the cosine of the angle of rotation is 1/sqrt(3), therefore the rotation matrix for this second rotation about the x-axis is:
| > |
M2 := matrix([[1,0,0],[0,cos_angle,-sin_angle],[0,sin_angle,cos_angle]]); |
So the matrix representing the rotation is the matrix product of these two rotations:
| > |
test_rot2 := simplify(evalm(M &* test)); |
Finally I am asked to have Maple compute the inverse of this matrix:
3. Our next task is to find the matrix that rotates counterclockwise by an angle φ about the line segement from point (1,1,1) to the origin. We are given the hint that we should be thinking of Minv*R*M. In in fact, this makes sense, because what we are doing is rotating the axis of rotation onto the z-axis, then applying a rotation about the z-axis (which corresponds to our original (1,1,1) axis), then inverting the rotation. Therefore a quick bit of Maple should find this rotation matrix:
| > |
S := simplify(evalm( Minv &* R &* M)); |
a. And now we confirm that a rotation of 120? just swaps axes. To do this, I substitute phi = 120? = 2*Pi/3 (radians) into the matrix S and then test the resulting matrix:
| > |
S120 := simplify(subs(phi=2*Pi/3,matrix(S))); |
| > |
ihat := vector ([1,0,0]); jhat := vector([0,1,0]); khat := vector([0,0,1]); |
| > |
inew := evalm( S120 &* ihat); jnew := evalm( S120 &* jhat); knew := evalm( S120 &* khat); |
b. Now see where (1,2,4) goes after a rotation of 60? about this axis.
| > |
S60 := simplify(subs(phi=Pi/3,matrix(S))); |
| > |
vec124 := vector([1,2,4]); vec124_new := evalm(S60 &* vec124); |
c. See where point (1,1,0) goes after a 90? rotation about this axis.
| > |
S90 := simplify(subs(phi=Pi/2,matrix(S))); |
| > |
vec110 := vector([1,1,0]); vec110_new := evalm(S90 &* vec110); |