ECSE-4750 Computer Graphics, Rensselaer Polytechnic Institute, Midterm Exam, Fall 2012, 11 Oct 2012 4-5:30

Answers in BLUE

NAME: _________ANSWERS___________________________ EMAIL:___________________________ RIN:______________

Answer every question.There are 5 pages with 20 questions, each worth 2 points. You may write FREE as the answer for two questions (and get the 2 points each).

This exam is open book: you may use calculators and any paper books and notes that you brought with you. You may not use computers or communication devices, or share material with other students.

  1. _____/(2 points) What does the following code do:
      glFrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 100.0);
      glOrtho(-5.0, 5.0, -5.0, 5.0, 5.0, 100.0);
    It does nothing that you probably want. glOrtho modifies the projection matrix, which was already modified by glFrustum. You should call only one.
  2. _____/(2 points) What display technology depends on the ability of an electric field to straighten out a corkscrew molecule?
  3. ________/2 Why can the following not possibly be a 3D Cartesian rotation matrix?
    {$ \begin{pmatrix} 1& 0 &0\\1 & 0 &0\\0& 0 &1\end{pmatrix} $}
    Its determinant is not 1. Or, the center column's length is not 1. There are also other correct answers.
  4. ________/2 If a=(1,2,3) then write {$(a\cdot p)\, a$} as a matrix M, depending only on {$a$}, times {$p$}. The answer is on Rotation3D. {$$\left(\begin{array}{ccc}

1 & 2 & 3\\ 2 & 4 & 6 \\ 3 & 6 & 9 \\ \end{array}\right) $$}

  1. ______/2 Can the volume of a small cube change when its vertices are rotated? (yes or no). Why (not)?
    No since its volume is the product of its sides multiplied by its determinant. The sides' lengths don't change when rotated. The determinant stays 1.
  2. _____/2 Why does OpenGL contain primitives, like triangle fans, that are not necessary (since you could draw the triangles separately)?
    For efficiency. If you can make your object's faces to be mostly fans and strips, then it takes down to 1/3 as much space to represent it. That can translate into increased speed.
  3. _____/2 Why do we consider color to have three dimensions, such as RGB? There are an infinite number of visible wavelengths.
    Because your eye has three types of color receptors. I'm ignoring color-blind people and tetrachromats.
  4. _____/2 What is the event loop?
    It's the piece of code that your program transitions to after setting things up. It loops, waiting for events such as user inputs and state changes. When an event for which you've defined a callback occurs, the event loop calls the callback. When finished, the callback returns to the event loop, which waits for the next event.
  5. _____/2 What is it about how display lists are constructed that prevents you from creating an infinite loop, where list 3 might call list 4 and list 4 calls list 3?
    You can't call a display list until it's been constructed. You can't edit an existing list. So, you can't make a loop.
  6. ____/2 Since the routine specified in glutDisplayFunc takes no arguments, how do you get data from other routines to it?
    Using global variables (or shared memory or an external file, or ...).
  7. _____/2 Give one disadvantage of standards.
    They tend to include only things that all major vendors have, and so they lack cutting edge features. They take years to formalize, and so lag the state of the art, even if all the vendors agree.
  8. ____/2 What's the dot product of these 2 vectors: (1,2,3), (4,5,6)?
    4+10+18 = 32.
  9. ____/2 One property of a well designed font is that different characters may have different widths. E.g., m is wider than i. This could be a problem when writing a character string in OpenGL since you'd have to know the width of each character and advance the raster position the correct amount after drawing each character. However OpenGL makes things easy for you. How?
    OpenGL has a pointer to where the next char should be drawn. Initially you set it. After each char is drawn, OpenGL advances the pointer by the width of that char.
  10. ____/2 What would look different in the resulting image if you changed the 1.0 to -1.0 in the following line?
    gluLookAt(camera.getZoomDistance() * sin(camera.getViewDirection()*PI/180.0), 0.0, camera.getZoomDistance() * cos(camera.getViewDirection()*PI/180.0), 0.0, 0.0, 0.0, 0.0, 1.0 , 0.0);
    It would flip upside down.
  11. ____/2 What feature in OpenGL is used to display the closest object when several objects overlap the same pixel?
    The depth, aka Z, buffer.
  12. ____/2 Give the 4x4 matrix for a 180 degree rotation about the Z axis followed by a translation by (0,0,4).
    {$ \left(\begin{array}{cccc} -1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \\ 0 & 0 & 1 & 4 \\ 0 & 0 & 0 & 1 \end{array}\right) $}
  13. ____/2 Since the Z buffer looks so useful, why is it not enabled by default? Give 2 reasons.
    It may be faster and use less graphics memory not to use it. (That reason is becoming less important as GPUs get bigger and faster.) Being able to turn it on and off can be useful, see ballAndTorusWithShadow.
  14. ____/2 When OpenGL calls a mouse or keyboard callback routine, there is a small problem with the cursor coordinates that OpenGL passes to the routine, if you wish to use the cursor location to draw something. What is this problem?
    The windowing system's origin is the top left. The callback routine is given the cursor's location in those coordinates. OpenGL's origin is at the bottom left (unless you're doing something complicated). You convert by subtracting the y-coordinate from the window height.
  15. ____/2 Assume that you have a model coordinate space with corners (0,100) and (300,200). You wish to map points in it to a rectangular window with corners (0,0) and (2,1). The center of the model coordinate space must map to the center of the window. X and Y must scale the same. The model coordinate space must touch the opposite sides of the window in one direction (x or y) and be inside the borders of the window in the other direction (y or x).
    Compute what the transformations for X and Y should be, in this form:
    X' = s X + dx
    Y' = s Y + dy
    I.e., tell me what s, dx, and dy are.
    The model's size is 300x100. The window's size is 2x1. W/o keeping the same aspect ratio, x would scale by 1/150 and y by 1/100. To keep the object's aspect ratio the same and in the window, s=min(1/150,1/100); s=1/150. The center of the model (150,150) transforms to (1,1/2) by x'=x/150+dx, y'=y/150+dy. So, 1=150/150+dx and 1/2=150/150+dy, so dx=0 and dy=-1/2.
  16. ____/2 If you call glutCreateWindow a second time in the program, which one of the following happens?
    1. a new window replaces the old one
    2. a new window is created, and the old one still remains
    3. nothing happens
    4. an error message is printed and the program exits
    5. the computer executes the HCF (halt and catch fire) machine instruction.

end of exam