Skip to main content

CG Homework 5 solution

  1. (2 pts) What is the angle (in degrees) between these two vectors: (1,2,0), (1,3,5)?

    a=(1,2,0). b=(1,3,5) a.b=7. |a|=sqrt(5). |b|=sqrt(35). cos t = 7/sqrt(5x35).

  2. (2 pts) (Reverse engineering rotations) In 2D, if the point (4,2) rotates about the origin to (2,-4), what's the angle?

    They're perpendicular. t=270 degrees.

  3. (2 pts) Give the matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}4\\2\\5\end{pmatrix} \times p\).

    Use https://wrf.ecse.rpi.edu/pmwiki/Research/Rotation3D

    \(M=\begin{pmatrix} 0 & -5 & 2\\ 5 & 0 & -4\\ -2 & 4 & 0 \end{pmatrix}\)

  4. (2 pts) Give the matrix M that has this property: for all vectors p, \(Mp = \left( \begin{pmatrix}2\\5\\4\end{pmatrix} \cdot p \right) \begin{pmatrix}2\\5\\4\end{pmatrix}\).

    \(M=\begin{pmatrix} 4 & 10 & 8\\10 & 25 & 20\\ 8&20&16 \end{pmatrix}\)

  5. (2 pts) Why can the following not possibly be a 3D Cartesian rotation matrix?

    \(\begin{pmatrix} 3& 0 &0\\1 & 0 &0\\0& 0 &1\end{pmatrix}\)

    1st column's length is not 1.

  6. (2 pts) Use any method (not involving soliciting answers on the internet) to rotate the point (6,6,9) by 120 degrees about the axis (2,2,3). Explain your method. (E.g., if you saw the answer in a vision, are your visions generally accurate?)

    Point is on axis and so doesn't move. (6,6,9).

  7. (2 pts) Can the volume of a small cube change when its vertices are rotated? (yes or no). Why (not)?

    No because distances and angles don't change.

  8. (2 pts) What is the ''event loop''?

    Display controller (or whatever) waits, perhaps in a small loop, for an event, like mouse click. Then, if the user has registered a callback routine, controller calls it to handle the event. When the callback routine finishes, it returns to the controller to wait for the next event. This is a reasonable API when there are many events, and each one is triggered rarely.

  9. (2 pts) Why does putting all your vertices into an array and telling OpenGL about it make a big graphics program faster?

    The previous OpenGL version used a function call for each vertex, which sent each vertex's data to the GPU separately. That lot of calls took more time.

  10. (2 pts) Since the Z (aka depth) buffer looks so useful, why is it not enabled by default?

    1. It takes time and memory.
    2. This gives the user control over whether or not to use it.
  11. (2 pts) What's the quaternion representing a rotation of 180 degrees about the axis (1,0,0)?

    q=i.

  12. (2 pts) Use the quaternion formulation to rotate the point (0,1,0) by 180 degrees about the axis (1,0,0).

    q=i, p=j, p'=qpq* = i j (-i) = -j. new point = (0,-1,0).

  13. (2 pts) Use the vector formulation to rotate the point (0,1,0) by 180 degrees about the axis (1,0,0).

    p' = (0,1,0) (-1) + 0 (1,0,0) + (0,0,1) 0 = (0,-1,0)

    You could use intuition to see that the point is perpendicular to the axis and go from there.

  14. (14) Extend your program that displays the Starship Enterprise as follows:

    1. Do the rotation in the vertex shader instead of in the javascript program.
    2. Make the color of each pixel depend on its z-value.

    Whatever is handed in should indicate that the student has done this. TA does not need to run the program.

(Total: 40 points.)