**CS 351 Assignment 5: 2D Transformations & Viewing**

*Justin Russell & Adam Lowenstein*

**Abstract**

In this assignment, our goal was to create, transform, and manipulate images using matrices. The matrix technique allowed us to define all subcomponents of an image however we chose: size, shape, angle, location, and any other attribute of a particular group of shapes could be stored within an array and altered using a local transformation matrix. For example, all elements of our spaceship in the image below are created as basic elements - unit squares, unit circles, basic polylines and polygons, etc. - and then stored in an array that is manipulated easily using the LTM. Then, using a global transformation matrix, we were able to alter all the elements simultaneously, generating images such as those shown below.

**Description**

All of our images in this project were based almost entirely on matrix transformations, so the first thing we did in this project was define a matrix type structure and a (large) number of matrix operations to control how matrices were used and implemented. After successfully building our matrix library, we tested it on code provided by Professor Maxwell, generating the first of the images shown in the "Algorithms & Pictures" section below. Then, using Professor Maxwell's code as a starting point, we developed our own spaceship. What started out as a simple medley of transformed unit squares and circles turned into an animated GIF of a spaceship hovering in place (seen below) and then, after much tweaking, the orbiting spaceship show above. After generating these spaceship animations, we created a viewing pipeline that simulated a camera panning across our interplanetary scene (as shown in the last image below).

**Algorithms & Pictures**

This picture implemented Professor Maxwell's code and confirmed that our matrix library was functioning correctly. The matrix library was a collection of matrix operations and other linear algebra operations.

The picture below shows our spaceship enlarged to fill a 500 x 600 window. It was enlarged using a GTM. In addition to using a unitCircle array and unitSquare array, we created two additional shapes: a polyline to create the lazers between the wings and a polygon to simulate the fire coming from our spaceship, since it goes so fast.

The image below is a representation of the panning effect created to demonstrate a view pipeline:

**Conclusion**

In this project, we learned a lot about efficient graphics creation through the use of matrices. Operations that would have taken us an impossible amount of time using our old manual techniques became achievable in a slightly more reasonable timeframe, and the control with which we can alter and customize our images increased greatly. We also learned how to create animated gifs. The techniques (and libraries) that we developed in this project will be very applicable throughout the rest of the semester.