Midterm 1 Guide

Past Exams

Study Guide

The following topics could appear on midterm 1. This list could shrink or expand (which would be announced in class).

You will be able to bring one hand written single or double sided sheet of notes into the exam

2D coordinate transforms

Vectors

3D transforms and matrices

OpenGL/GLSL/glm

Rasterization

and depth buffer algorithms

Sample Questions

2D Coordinate Transforms

Assume that we have world coordinates defined as follows:

figure-01

We would like to map these coordinates to pixel coordinates for a window with the following coordinate values:

figure-02

Assuming that we know that the mapping will contain a scale and translate and thus be of the form:

Solve for , , , and . Hint: writing out the constraints - for example we know that when we send left through the mapping we want it to equal , i.e.,

How is the pixel coordinate system different then the world coordinate system? How do we make sure that a circle in the world coordinate system does not get drawn as an ellipse in the pixel coordinate system?

Vectors

Given the following vectors:

and the scalar

Compute:

1.

2.

3.

4.

5. what is the angle between and (don’t compute it just write solution in terms of )

6. what is the projection of onto


Given the points and write the implicit equation for a line in vector form (i.e. compute the appropriate and ).

Is the point on the line or above or below the line?


What is the equation for a plane with the normal going through the origin?

What is the equation for the planes with the same normal but which include the point ?

2D Transform Matrices

Given the following 2D transform matrices:

Name what type of 2D transformation is associated with each matrix and say something about the magnitude of the transform for x or y or angle, as applicable.

If these are 2D transforms, why are they 3x3 matrices?

Compute (that is, write out the composite matrix) and Draw the result of applying the composite matrix to the following figure. Include coordinate labels for your completed drawing:

figure-03

OpenGL / glm

Carefully draw the result of the following glm code assuming that the DrawFlower() function draws the image below without the dashed lines, which are just there to show you the size of the flower (i.e. the bounding box of the flower, ranges from a lower left corner of and extends to an upper right corner of ). Recall that rotations are specified as counter-clockwise.

Carefully read all the code below before drawing.

void SetModel(glm::vec3 trans, float sf, float ang, glm::vec3 axis) {
  glm::mat4 Trans = glm::translate( glm::mat4(1.0f), trans);
  glm::mat4 Scale = glm::scale( glm::mat4(1.0f), glm::vec3(sf));
  glm::mat4 Rot = glm::rotate( glm::mat4(1.0f), angle, axis);
  glm::mat4 Model = Trans*Scale*Rot;
  safe_glUniformMatrix4fv(h_uModelMatrix, glm::value_ptr(Model));
}

/* ... */

/*in Draw function */
SetModel(glm::vec3(0), 1, 45, glm::vec3(0, 0, 1));
DrawFlower();
SetModel(glm::vec3(4, 0, 0), 1, -45, glm::vec3(0, 0, 1));
DrawFlower();

figure-04

figure-05