Week 5 Tutorial

Question 1: 3D Affine Transformations

What coordinate frames do the following affine matrices represent?

M1 = [[  1,  0,  0,  0],
      [  0,  1, -1,  0], 
      [  0,  1,  1,  0],
      [  0,  0,  0,  1]]

M2 = [[  2,  0,  0,  2],
      [  0, -1,  0,  1],
      [  0,  0,  1,  0],
      [  0,  0,  0,  1]]

M3 = [[  1,  1,  1,  0],
      [  0,  1,  1,  0],
      [  0,  0,  1,  0]
      [  0,  0,  0,  1]]

Hint: rememeber M = [i, j, k, phi].

Question 2: 3D Rotations

If you rotate a coordinate frame by 90 degrees about x and then rotate the resulting frame by 90 degrees about y, what is the resulting frame? What is the matrix for the combined transformation? What happens if you reverse the order of the rotations?

Question 3: 3D Cameras

Consider the following OpenGL code:

gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
GLU glu = new GLU();
glu.gluLookAt(0, -3, 3, 0, 1, 0, 0, 0, 1);

gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(-4, 4, -3, 3, 1, 4); 

What is the camera's local coordinate frame (in world coordinates) after this call?

What is the resulting model-view transform?

Sketch the view volume in world coordinates.

Sketch the view volume in camera coordinates.

What if line 8 were changed to:

gl.glFrustum(-4, 4, -3, 3, 1, 4); 

What is the new view volume?

Question 4: Perspective Projections

Consider the following code:

        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();

        GLU glu = new GLU();
        glu.gluPerspective(60, 1, 1, 10);
        
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();

        gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
        gl.glBegin(GL2.GL_QUADS);
        {
            gl.glVertex3d(1, 1, -2);
            gl.glVertex3d(0, 1, -2);
            gl.glVertex3d(0, 0, -2);
            gl.glVertex3d(1, 0, -2);

            gl.glVertex3d(0, 1, -4);
            gl.glVertex3d(-1, 1, -4);
            gl.glVertex3d(-1, 0, -4);
            gl.glVertex3d(0, 0, -4);
        }
        gl.glEnd();

Question 5: 3D Modeling

Question 6 (advanced - not examinable):

A rotation about any arbitrary axis can be decomposed into a series of rotations about the X, Y or Z axes. How would you compute such a decomposition? (There are many different ways of doing this.)