CS 420 Computer Graphics


Homework 3
Due Nov 23, 2009 ( Mon )

  1. ( 10 points ) The projection of a vector A onto a vector B ( parallel component ) is given by ProjB A = ( A.B / |B|2 ) B and the component of A that is perpendicular to B is given by PerpB A = A - ProjB A = A - ( A.B / |B|2 ) B

    Let A = ( 2, 2, 1 ) and B = ( 1, -2, 0 ), calculate ProjB A and PerpB A

  2. ( 10 points ) Find the 4x4 transformation matrix corresponding to the OpenGL command: glFrustum ( -1.0, 1.0, -1.0, 1.0, 4, 8 );

    Then find the composite transformation matrix of a rotation about the z-axis by 30o. followed by the above glFrustum() matrix operation.

  3. ( 15 points ) Find the 4x4 transformation matrix of the rotation about the axis passing through points (0, 0, 0 ) and ( 1, 1, 1 ) for 30o. ( Hint: Such a rotation is equivalent to the composite of:
    1. rotation about z-axis for 45o, then
    2. rotation about x-axis for -35.26 o ( = -sin -1(1/sqrt(3)), then
    3. rotation about y-axis for 30o, then
    4. rotation about x-axis for 35.26 o, then
    5. rotation about z-axis for -45o.
    Why? ) What's the destination of the point (1, 0, 0 ) after such a rotation?

    Write a simple OpenGL program to check if your calculation is correct.

  4. ( 10 points ) Suppose you want to render a scene where all objects are bounded by the box -1 ≤ x ≤ 2, 6 ≤ y ≤ 8, and 0 ≤ z ≤ 6.

    and the viewpoint ( 'camera' ) is at ( 8, 6, 9 ). Find the angle of the field-of-view for the viewpoint.

  5. ( 25 points )
    a ) Write a program to draw the following robot arm
    b) Add features to a) so that a user can control the movements of the robot arm by entering commands from the keyboard. The movements include rotate, swing, and translation of the arm and the finger gripping motions.

    c) ( Extra Credit ) Add a 3-D object ( e.g. a barn ) in the graphics and allow a user to move the arm to pick up the object.

    Submit your programs along with sample outputs and make a demo to the instructor before a class or during the office hours.