CSCI 480/580 Lecture 19 - In-Class Problems

  1. The viewport matrix maps the canonical view volume (normalized device coordinates) to Julia (y=i, x=j, 1-indexed) pixel coordinates for a given canvas \(\mathbf{h}\) and \(\mathbf{w}\).

    We derived the scalar formulas for the coordinates to be: \[ \begin{align*} x_p &= \frac{(x_v + 1)}{2}w + \frac{1}{2}\\ y_p &= \frac{(-y_v + 1)}{2}h + \frac{1}{2}\\ z_p &= z_v \end{align*} \]

    Write the 4x4 viewport matrix that accomplishes this transformation.

  2. An orthographic projection matrix can be specified by giving two opposite corners of the view volume.

    We can accomplish this with a sequence of simpler steps:

    1. Translate the bottom, left, near corner to the origin
    2. Scale the width, height, and depth of the volume each to 2
    3. Translate the center of the now-2x2x2 cube to the origin.

    Write the 4x4 projection matrix that accomplishes this transformation.

  3. The camera matrix transforms world coordinates into a camera’s local coordinate frame.

    Write the matrix that accomplishes this transformation.