CSCI 480/580 Lecture 18 - In-Class Problems / Mini-Lab

Grab the mini-lab code here. Unzip it and open up a Julia REPL in the same directory as the code. You may need to go to the package prompt (press ]) and run add Luxor, and perhaps a couple other packages like FileIO, StaticArrays, and ImageIO.

To make sure you're set up, at the Julia REPL, run include("wire.jl"). It should run without error and produce an output file called luxor_drawing.png. If you're running in VS Code or Juno, you should see the image preview pop up. Currently, our tiny adorable cube is just barely visible in the top left of the image.

  1. The canvas width and height are set to 400. Build a viewport matrix that maps points in normalized device coordinates onto the image plane. In other words, map the space of coordinates to a space where and range from 1 to cw and ch, respectively, and is left unchanged. Note that the line drawing library we're using takes and coordinates with (0,0) at the top left and pointing right and pointing down. If your answer matches mine, your image will match ex1.png, included iwth the code.

  2. The orthographic view volume is specified using left, right, top, bottom, near, and far planes. Construct an orthographic projection matrix that uses the following three steps to scale the view volume into normalized device coordinates / the canonical view volume:

    • Translate so the left, bottom, near corner of the volume is at the origin.
    • Scale the view volume so it has dimensions 2x2x2
    • Translate the 2x2x2 volume so that the origin is in the center of the volume.

    If your answer matches mine, your image will match ex2.png, included iwth the code.

  3. Finally, we'll move the camera somewhere more interesting. The camera is specified using eye, at, and up as we've discussed in the past. I constructed the camera basis vectors (u, v, and w) for you using our standard sequence of cross-products. Given the basis vectors and eye point, build the camera matrix that will cause the scene to be rendered by a camera in that basis. If your answer matches mine, your image will match ex3.png, included iwth the code.