Difference between revisions of "Project1Fall13"
(→2. Animated Scene (55 points)) |
(→1. Vectors and Matrices (45 points)) |
||
Line 15: | Line 15: | ||
==1. Vectors and Matrices (45 points)== | ==1. Vectors and Matrices (45 points)== | ||
− | + | Start with the spinning cube from the base code. Part of the project is a class named Matrix4. Use it as a template and implement matrix and vector classes with frequently used functionality. You can use the C++ class shown below as a basis for 3-component vectors. Create separate classes for a Vector3 and a Vector4, vectors with three or four components, respectively. The Vector4 type includes the homogeneous coordinate (w component), which helps distinguish points from vectors. There only needs to be a matrix class for 4x4 matrices. | |
[[Image:sample-vector-class-800.png]] | [[Image:sample-vector-class-800.png]] |
Revision as of 23:49, 26 September 2013
Contents |
Project 1: Applied Linear Algebra
Your project should build on the provided base code. Before you start with this project, you will need to look through the base code and get familiar with it.
This project has three parts, but only the first two are mandatory to get full credit (100 points). The number of points you can get for each part is indicated below. In the first part you will create classes for vectors and matrices. You will use this functionality in the remaining projects throughout the quarter. In the second part of this project you will construct an animated scene with moving objects whose motion depends on one another.
The third part is optional. We make suggestions for how to extend your solution with some additional features. You will get extra credit for completing those.
Note that in this project you are not allowed to use OpenGL or GLUT matrix routines, such as glRotate, glTranslate, or glScale, because we want you to use your own matrix routines.
This project is due on Friday, October 4th. You will need to present your project in CSE basement labs starting at 1:30pm that day, or during one of the TA/tutors' office hours before the due date. For this project you are allowed to work in teams of two. In this case both team members need to be present during the homework presentation.
TA Matteo Mannino is going to introduce this homework assignment in Center Hall 105 on Monday, September 30th at 3pm.
1. Vectors and Matrices (45 points)
Start with the spinning cube from the base code. Part of the project is a class named Matrix4. Use it as a template and implement matrix and vector classes with frequently used functionality. You can use the C++ class shown below as a basis for 3-component vectors. Create separate classes for a Vector3 and a Vector4, vectors with three or four components, respectively. The Vector4 type includes the homogeneous coordinate (w component), which helps distinguish points from vectors. There only needs to be a matrix class for 4x4 matrices.
1a. Vectors (One point for each method for a total of 23 points)
Implement the following methods in your Vector3 class:
- A constructor with three parameters for the vector coordinates
- Element access 'set': set the vector coordinates
- Element access 'get': return a specific coordinate of the vector
- Vector addition
- Overload operator '+' for addition
- Vector subtraction
- Overload operator '-' for subtraction
- Negation
- Scale (multiplication with scalar value)
- Dot product
- Cross product
- Magnitude (length of vector)
- Normalize
- Print (display the vector's components numerically on the screen)
Implement the following methods in your Vector4 class:
- A constructor with three (or four, optionally) parameters for the point coordinates
- Element access 'set': set the (four) point coordinates
- Element access 'get': return one of the four point coordinates
- Vector addition
- Overload operator '+' for addition
- Vector subtraction
- Overload operator '-' for subtraction
- Dehomogenize (make fourth component equal to 1)
- Print (display the point's components numerically on the screen)
1b. Matrices (Two points for each method for a total of 22 points)
Implement the following methods in your Matrix4 class:
- Constructor with 16 parameters to set the values of the matrix
- Multiply (matrix-times-matrix)
- Multiply (matrix-times-vector)
- Make a rotation matrix about the x axis
- Make a rotation matrix about the y axis
- Make a rotation matrix about the z axis
- Make a rotation matrix about an arbitrary (unit) axis
- Make a non-uniform scaling matrix
- Make a translation matrix
- Print the matrix (display all 16 matrix components numerically on the screen in a 4x4 array)
- Transpose the matrix
2. Animated Cube (55 points)
Start with the base code with the spinning cube.
3. Tessellated Object (optional, 10 points)
The base OpenGL library only provides support for modeling and rendering simple points, lines, and polygons. Neither 3D objects, nor commonly used 2D objects such as circles, are directly available.
OpenGL and GLUT offer utility functions to allow you to render such shapes, which you might have done in part 2 of the project. In part 3 you are not allowed to use these utility functions.
To get the optional credit, you will have to implement your own tessellation of a rotationally symmetrical object, for example a cylinder, sphere, cone or torus. Your object should use base OpenGL functions to draw a number of triangles or quads that constitute the 3D object. You need to compute the vertices and build the quads/triangles yourself. (7 points)
Your algorithm needs to have at least one parameter to control the tessellation level (proportional to the number of quads/triangles the object consists of), and you need to be able to change this parameter (in source code is okay) during your homework presentation. (2 points)
Your quads/triangles need to be either wire framed, have different colors, or be shaded so that they can be easily distinguished. (1 point)
Below are images of a tessellated sphere (using quads) and a torus (using triangles) for inspiration:
Helpful link: