Sections:
For this lab we created a series of 3D matrix transformations that we can apply to a new class created called a point3D, which is a 4-vector storing values for x, y, z, and h. These transformations and represented in a 4x4 matrix. All of the transformations are mutators, meaning that they take the current matrix and do the transformation on that matrix. Listed below are the functions we developed to do these transformations:
class matrix:
| translate3D(double tx, double ty, double tz) | Causes the matrix to translate by the specificed amount in x, y, and z. |
|   |   |
| scale3D(double s) | Causes the matrix to scale by the specified amount in all directions |
| scale3D(double sx, double sy, double sz) | Causes the matrix to scale by the specified amount in each direction |
| scale3D(point3D center, double s) | Causes the matrix to scale by the specified amount in all directions, around the specified point |
| scale3D(point3D center, double sx, double sy, double sz) | Causes the matrix to scale by the specified amount in each direction, around the specified point |
| scale3D(point3D center, double theta, double sx, double sy, double sz) | Causes the matrix to scale by the specified amount in each direction, around the specified point, at the given angle |
|   |   |
| rotate3Dz(double theta) | Causes the matrix to rotate by the specified amount |
| rotate3Dz(point3D center, double theta) | Causes the matrix to rotate by the specified amount, around the specified point |
|   |   |
| sheer3Dx(double shx) | Causes the matrix to sheer in the x direction |
| sheer3Dy(double shy) | Causes the matrix to sheer in the y direction |
For this lab we were asked to create a model of the Starship Enterprise or another cool (nerdy?) spaceship. Andrew did model the Enterprise and Will choose to model an X-Wing from Star Wars. Will's model required 9 instances of the unit box and 6 instances of the unit line. Andrew's model required a unit circle and 4 instances of a unit box.
Here are the models we developed:
![]() Will's X-Wing |
![]() Andrew's Enterprise (Rough version) |
We were then asked to create a model of the spaceship orbiting a planet. Will made two images, one with it orbiting a simple circle (representing a planet) and then another of it orbiting the moon. Andrew made an image of his Enterprise, filled, with circular gradient shading, orbiting a nebula.
For the final part of this lab, we were asked to create an image that scrolled past the rotating ship, using our viewing pipeline. Below are the images we created:
![]() X-Wing fly-by (Click image for animation) |
![]() Enterprise Fly-by (Click image for larger version!) |
General Extensions:
As extensions, Will and Andrew both made animated gif movie sequences of our space ships rotating around planets and scrolling off the screen while rotating. Additionally, we shaded our ships and Andrew used a circular gradient to fill the Enterprise's dish. We also put our ships over cool space backgrounds! Finally, we also had a creative use of multiple ships -- see below.
Space Warp!
Additionally, we added a new pen option: alpha. We could always do alpha blending, but now it's a pen option, called with image.setPenAlpha(unsigned char) and image.getPenAlpha(). Here is an example image using both alpha blending and multiple versions of the Enterprise made with some nested for-loops:
![]() Andrew's Space Warp! Click for large, full-quality version. |