LAB 4 - Jesse and Shingo CS40/ENGR26



HOME Lab1 Lab2 Lab3 Lab4 Lab5 Lab6 Lab7 Lab8 Lab9 Lab10 CODE
Jesse's Portfolio Shingo's Portfolio



LAB DESCRIPTION



In the last lab we created pictures based on primitives by measuring point locations relative to world coordinates. Making pictures this was is a daunting task. Ultimately it is much more efficient practically and conceptually to create a picture of an object around a local coordinate system and then transform the object into the appropriate position by moving, rotating, or scaling the object. This method also makes copying an object and transforming its copies much more efficient. This allows the easy creation of a fleet of ships rather than just a ship.

Such methodology and its benefits are the focus of lab 4. In this lab we created a library of matrix transformations and applied them to primitives to create objects including the starship enterprise shown below. Matrix transformations could then used to globally transform the entire object.

Moving, rotating, or otherwise transorming an object is done by transforming the points defining that object. For instance, a rectangle can be moved by translating its four points. Rotating it relative to the origin is done by simply multiplying a rotation matrix by the point parameters (x,y,z). Rotating an object in place (locally) is a little more complicated. This is done by translating it to the origin, rotating it, and then moving it back into place. The three matrices, each describing one of these operations are premultiplied together to yeild a transformation matrix. This matrix can also be used to transform other objects in the same fashion. Thus a series of operations can be stored in a single matrix and used as a piece of a variety of larger operations. This can ultimately create complicated effects such as a ship orbiting a planet as shown below.

Matrix operations producing a final picture can be grouped into a few broad categories. Local Transformation matrices (LTM) are used to move a primitive relative to a local origin to create an object (a ship, table etc). Global transformation matrices transform objects relative to global (world) coordinates. This is used to place objects in a scene. This step would be used to describe where a chair is relative to the table. Finally, a view transformation matrix (VTM) transforms the world into appropriate coordinates for viewing on screen. This last step may not be necessary for simple pictures but its use soon becomes apparant when you want to simulate the effect of a camera panning a scene (see below) or for displaying a three dimensional scene on a two dimensional medium such as the screen. This will be done in later labs.

Required image 1: test of matrix library
Required image 2: Our Starship Enterprise

QUESTIONS

  1. Who did you work with on this assignment, and what tasks did each of you do?

  2. In general tasks for this assignment were split evenly and usually shared between Jesse and Shingo. The following table lists the tasks and division of labor (although we really collaborated on everything).

    TaskJessebothShingo
    Matrix LibraryX
    Starship ModelX
    Macro-RotationX
    VTMX
    writeupX

  3. Describe the mechanism you developed for handling the global transformation parameters and matrix.

  4. After creating the starship by transforming the points of unary primitives (unit square and circle) and drawing polygons and circles using those now correctly placed points, a matrix was used to translate the spaceship relative to the planet. Rotation for a single frame is also easily done. After translating the ship relative to the planet but still maintaining the planet at the origin, the ship can be rotated relative to the origin and consequently the center of the planet using a rotation matrix. Next a translation matrix can be used to move the entire scene to the center of the image.

    Rotation and global translation across a series of images (to create the animation below) required rewriting code so that the global rotation matrix and global translation matrix along with writing the image to a file could be done inside a for loop creating each image. This required keeping a copy of the GTM describing the position of the objects at the origin for use with the next frame and then inside the loop rotating relative to the origin before translating the scene to the right spot in the image file.
    Starship orbiting a planet

  5. Describe the mechanism you developed for handling the viewing pipeline parameters and transformation matrix.

  6. The viewing pipeline is implemented within the loop creating frames for animation after Global transformations which include moving the ship away from the center of the planet and then rotating it. The VTM matrix is created as an identity matrix. Transforms are then applied including scaling to the size of the image to be created and translating relative to the scene (ie the objects). This matrix is then applied to the objects of the scene through the use of xform_shape functions which essentially multiply the transform matrix by the series of points in the shape.

  7. Once you had the code in place, what was the process and how difficult was it to modify the view window and the position of the Enterprise?

  8. Once the code was in place, modifying parameters for the view window and global position of the enterprise was relatively easy. Rather than having to individually move each part of the Enterprise object, the entire object could be moved by modifying a single transformation matrix and applying it to all parts of the enterprise.

    The view window was also easy to modify. A VTM (view transformation matrix) is used to describe the transformation from world coordinates to the screen. In this process the objects in the world can be translated. A translation matrix accomplishing this is multiplied with the VTM to create the effect and only this matrix need be modified to change the position of the view window and thus create the effect of a moving camera.

    Panning the scene

  9. If you extended this assignment in any way, describe what you did and how you did it. Include pictures, or links to pictures that show what you did.