CS 381  >  Test 2 Information & Week 8 Review Problems

CS 381, Fall 2003
Test 2 Information & Week 8 Review Problems

Test 2 Information

Test 2 will be given in class on Friday, November 7. It will take up the entire class meeting. The test will be worth 50 points and will cover all the course material between Test 1 and Test 2 (weeks 5 through 9). Note that, while the material of weeks 0–4 will not be explicitly covered on the test, knowledge of this material is still necessary, since the later material was based on it.

Referring to books, notes, or other students during the test will not be permitted.

The assignments, being oriented primarily toward programming, should not be considered a complete preparation for the test. Readings and review problems have been posted each week, as have lecture slides. You can expect the test to contain problems similar to the various review problems. Here are links to the other review-problem sets:

Week 8 review problems are given below. Answers are in the Answers section, below. Do not turn these in. We may certainly discuss any of these problems in class, if you want.

Problems

Note: On the test you will be expected to do problems like these without books or notes.
  1. When we write a function to draw an object, it is usually most convenient to have the object drawn with its center at the origin, even if that is not where we want it to appear in the scene. a. Explain. b. Maybe we do not want the center of the object to be at the origin. More generally, what should be at the origin?
     
  2. On their way through the OpenGL geometry pipeline, points pass through three transformations. a. List these three transformations. b. Which of the three is specified very differently from the others? c. During which phase of the geometry pipeline do these transformations occur?
     
  3. Explain the normal usage of the model/view and projection transformations. What is each used for? What commands do we typically use for each?
     
  4. Fill in the blanks:
    Model/view can effectively store a sequence of transformations. We think of those at the head of the sequence (later in the code) as moving ________. We think of those at the tail of the sequence (earlier in the code) as moving ________ or ________.

     
  5. The model/view transformation is named that way because we use it to hold both modeling transformations and viewing transformations. a. Explain the conceptual difference between modelling and viewing. b. Explain the mathematical difference between modelling and viewing. c. In what order do modelling and viewing occur in the pipeline (not in the code)?
     
  6. We want to “roll” the camera, effectively rotating the entire scene counterclockwise 20°. a. What (single) function call does this transformation? Don’t worry about clockwise vs. counterclockwise. b. Where in the transformation-setting code should this call go?
     
  7. We want to rotate an object, about its natural x-axis, 40°. a. What (single) function call does this transformation? Don’t worry about clockwise vs. counterclockwise. b. Where in the transformation-setting code should this call go?
     
  8. Using glTranslate*, etc. to place the camera in such a way as to view a particular location, can be very tricky. How can we do this more easily?
     
  9. Suppose we wish to move the camera to the point (3, 2, 1), looking in the direction of the vector (7, 8, 9). a. I have not given you enough information to set up a transformation. What else do you need? b. Assuming the required information has been given, what (single) function call will set up the required transformation? c. Where in the transformation-setting code should this call go?
     
  10. Explain what the following function call does, and where in the code it should probably appear.
    gluLookAt(1., 2., 3., 4., 5., 6., 7., 8., 9.);

     
  11. Which of the following “classical views” can be produced using the OpenGL projection transformation? a. plan. b. elevation. c. isometric. d. 1-point perspective. e. 2-point perspective. f. 3-point perspective.
     
  12. Explain what the following function call does, and where in the code it should probably appear.
    gluPerspective(20., 1., 0.5, 10.);

     
  13. A problem we sometimes encounter when drawing a 3-D scene in OpenGL is that we will be looking directly at an object, but we cannot see the object (or anything else). What typically causes this?
     
  14. In order to be able to see as much as possible, we might want to move our near clipping plane very close and our far clipping plane very far away. Why should this generally be avoided?
     
  15. Compute the following matrix multiplication, followed by 4th-coordinate division.
    (
     1  0  0  0
    0 1 0 0
    0 0 1 0
    0 0 k 0
    ) (
    x
    y
    z
    1
    ) .

     
  16. Why is the 4th-coordinate division part of the OpenGL pipeline? (What operations require it?)
     
  17. a. Under what circumstances is it often inconvenient to rebuild the model/view transformation from scratch each time the display function is called? b. How can we do things more conveniently?
     
  18. In what type of variable does OpenGL store matrices?
     

Answers

    1. We draw the object in this way to make it convenient to place it using transformations. If the center is at the origin then,
      • we can rotate the object about its center using glRotate*,
      • we can scale the object about its center using glScale* and
      • we can place the center of the object using glTranslate*.
    2. The point we really want to be drawn at the origin is the natural point about which to rotate the object, whatever that may be. For may objects, this is their center. But for an arm (say), this point would probably be at the shoulder.
    1. We have discussed the following transformations.
      • Model/view.
      • Projection.
      • Viewport.
    2. The viewport transformation is specified differently from the others. Model/view and projection are specified by setting the proper matrix mode and using transformation commands. Viewport is specified using glViewport.
    3. The transformations occur in the vertex opertations phase of the geometry pipeline.
  1. Model/view can effectively store a sequence of transformations. We think of those at the head of the sequence (later in the code) as moving an object. We think of those at the tail of the sequence (earlier in the code) as moving the entire scene or the camera.
    1. Conceptually, we use viewing transformations to place the camera in the world. We use modelling transformations to place objects in the world.
    2. From a mathematical point of the view, the two are identical; there is no difference.
    3. Modeling comes before viewing in the pipeline (and after viewing in the code).
    1. The required call is the following.
      glRotated(20, 0,0,1);
    2. This call should go at the beginning of the transformation-setting code.
    1. The required call is the following.
      glRotated(40, 1,0,0);
    2. This call should go just before we draw the object.
  2. Camera placement with a particular viewing location in mind is easily done using gluLookAt.
    1. Information about camera “roll” has not been given. Generally, we specify this by indicating which direction is up.
    2. If up is given in ux, uy, uz, then the required call is the following.
      gluLookAt(3., 2., 1., 7.-3., 8.-2., 9.-1., ux, uy, uz);
    3. This command should go at the beginning of the transformation-setting code.
  3. This function call sets up a viewing transformation. The transformation is sets up places the camera at the point (1, 2, 3), looking toward the point (4, 5, 6), with “up” pointing as close as possible to the direction given by (7, 8, 9). The call should probably appear at or near the beginning of the code that sets up the model/view transformation, with GL_MODELVIEW mode in effect.
  4. Answer: a, b, c, d, e, f. They can all be produced.
  5. This function call sets up a perspective projection. The transformation gives a field of view of 20° vertically, with an aspect ratio (width/height) of 1, a near-plane distance of 0.5, and a far-plane distance of 10. The call should probably appear in the code that sets up the projection transformation, with GL_PROJECTION mode in effect.
  6. Looking directly at an object without seeing it is typically caused by the object being in front of the near clipping plane or behind the far clipping plane.
  7. We avoid spreading out the near and far clipping planes because this reduces the precision available for the depth test.
  8. First the multiplication.
    (
     1  0  0  0
    0 1 0 0
    0 0 1 0
    0 0 k 0
    ) (
    x
    y
    z
    1
    )  =  (
    x + 0·y + 0·z + 0·1
    x + 1·y + 0·z + 0·1
    x + 0·y + 1·z + 0·1
    x + 0·y + k·z + 0·1
    )  =  (
    x
    y
    z
    kz
    ) .
    Now the 4th-coordinate division.
    (
    x
    y
    z
    kz
    )  →  (
    x / kz
    y / kz
    z / kz
    )  =  (
    x / kz
    y / kz
    1 / k
    ) .
  9. The 4th-coordinate division is part of the pipeline so that perspective projection can be done. Perspective projection requires division, while matrix-vector multiplication uses only multiplication and addition. Thus we cannot do perspective projection using only matrix-vector multiplication.
    1. It is inconvenient to rebuild the model/view transformation from scratch each time the display function is called, when we implement a viewing interface that uses repeated camera transformations (for example, when “flying”).
    2. A convenient way to handle this is to save the current model/view transformation in a matrix variable. When the model/view transformation needs to change, we modify this variable appropriately.
    3. Then, instead of rebuilding the whole transformation in the display function, we simply use the value of this variable.
  10. OpenGL can store a matrix in an array of 16 GLdouble’s (or GLfloat’s).


CS 381, Fall 2003: Test 2 Information & Week 8 Review Problems / Last update: 6 Nov 2002 / Glenn G. Chappell / ffggc@uaf.edu