CS 248: Final Solutions

Question 4

Grader: Kekoa Proudfoot


4A (15 points)

In order to look at things from the point of view of the right hand, you needed to invert the transformations used to render the right hand. Those transformations were:

Translate(x,y);
Translate(0,2);
Translate(1,0);
Rotate(rangle);

The inverse of that, and the answer to this part of the question, was the inverse of each of the invidual transformations, in reverse order:

Rotate(-rangle);
Translate(-1,0);
Translate(0,-2);
Translate(-x,-y);
Or, simplified:
Rotate(-rangle);
Translate(-x-1,-y-2);

You got full credit if you gave one of these two answers or an equivalent.

If you got the transformations in the wrong order, you lost 5 points.

If you forgot to invert the transformations, you lost 5 points.

Partial credit was given if you got either of these two partially right, with partial credit being 2-3 points per part.

A few people misunderstood the question and tried to place a camera node somewhere in the code. 5 points were given for this answer.

If you didn't get any part of the question correct, but you made a reasonable attempt at an answer, you were given 3 points.


4B (15 points)

The point of this question was to invert the following 4x4 matrix, given that it consists of a rotation plus a translation:

[ux vx wx tx]
[uy vy wy ty]
[uz vz wz tz]
[ 0  0  0  1]

The matrix shown could be split into two matrices: a rotation matrix and a translation matrix. The order of the two matrices after the split was important:

[ux vx wx tx]   [1 0 0 tx]   [ux vx wx 0]
[uy vy wy ty]   [0 1 0 ty]   [uy vy wy 0]
[uz vz wz tz] = [0 0 1 tz] * [uz vz wz 0]
[ 0  0  0  1]   [0 0 0  1]   [ 0  0  0 1]

There were many ways to determine the right order for the matrices after the split. One of the simplest, given the information in the problem alone, was to make a guess at the order then verify that the product equaled the original matrix. However, if you recalled that this matrix was the orientation matrix (described in slide 3 of lecture 12), then you might have noticed that, to place an object at a given position and orientation, you first rotate the object, then second translate it to its new position. This corresponds to placing the rotation matrix on the right and the translation matrix on the left.

Given the original matrix split into two pieces, it is relatively straightforward to invert the matrix product if you remembered three general ideas:

  1. The inverse of a translation matrix is the translation matrix with the opposite signs on each of the translation components.
  2. The inverse of a rotation matrix is the rotation matrix's transpose.
  3. The inverse of a matrix product is the product of the inverse matrices ordered in reverse.

Given these, the inverse of the matrix is found as follows:

[ux vx wx tx] -1   ( [1 0 0 tx]   [ux vx wx 0] ) -1
[uy vy wy ty]      ( [0 1 0 ty]   [uy vy wy 0] )
[uz vz wz tz]    = ( [0 0 1 tz] * [uz vz wz 0] )
[ 0  0  0  1]      ( [0 0 0  1]   [ 0  0  0 1] )

                   [ux vx wx 0] -1   [1 0 0 tx] -1
                   [uy vy wy 0]      [0 1 0 ty]
                 = [ux vz wz 0]    * [0 0 1 tz]
                   [ 0  0  0 1]      [0 0 0  1]

                   [ux uy uz 0]   [1 0 0 -tx]
                   [vx vy vz 0]   [0 1 0 -ty]
                 = [wx wy wz 0] * [0 0 1 -tz]
                   [ 0  0  0 1]   [0 0 0  1 ]

                   [ux uy uz -ux*tx-uy*ty-uz*tz]
                   [vx vy vz -vx*tx-vy*ty-vz*tz]
                 = [wx wy wz -wx*tx-wy*ty-wz*tz]
                   [ 0  0  0          1        ]

                   [ux uy uz -dot(u,t)]
                   [vx vy vz -dot(v,t)]
                 = [wx wy wz -dot(w,t)]
                   [ 0  0  0     1    ]

The inverse matrix is, of course, a rigid body transformation. Not only does it satisfy the form of the original matrix, but if you transform an object by translating and rotating it, you can restore the object to its original position by reversing the translations and rotations. This restoration transformation is the inverse transformation; since it consists of translations and rotations, it is also a rigid body transformation.

Either of the last two forms shown above were acceptable for full credit.

If you got the translation part of the final matrix incorrect, you lost 5 points.

If you got the rotation part of the final matrix incorrect, you lost 5 points.

Partial credit was given on the basis of the steps leading up to your final answer, with partial credit typically being 2-3 points per part.

A fair number of people inverted the matrix as:

[ux uy uz -tx]
[vx vy vz -ty]
[wx wy wz -tz]
[ 0  0  0  1 ]
If you gave this solution, you lost 5 points, since it was important to note that you could not simply invert regions of a single matrix to arrive at the final inverted matrix; you had to break the matrix into pieces and invert the pieces separately.

If all you did was transpose the original matrix, you lost 10 points.

If you were one of the few that went for a brute force method, such as taking the adjoint matrix full of cofactors and multiplying it by one over the determinant of the original matrix, you were awarded full credit only if you simplified your answer. A very important observation to make if you went down this path was that, because u, v, and w are orthonormal, dot(u,v), dot(v,u), dot(v,w), dot(w,v), dot(w,u), and dot(u,w) are all zero, and dot(u,u), dot(v,v), and dot(w,w) are all one. If you did not expand your terms and simplify using these properties, you were given at most 5 points.

If you incorrectly answered that the inverse transformation was not a rigid body transformation, you lost 2 points. I did not deduct points if you gave the right answer for an incorrectly inverted matrix.

If you only answered whether or not you thought the inverse transformation was a rigid body transformation, and you got that right, you were given 3 points.

If you didn't get any part of the question correct, but you made a reasonable attempt at an answer, you were given 1-2 points.