Difference between revisions of "Project1Fall11"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
(New page: =Project 1: Vectors, Matrices, and Coordinate Transformations= Your project should build on the base code that we provide. You will find the code, documentation, and instructions for how ...)
 
(3. Animated Object (40 points))
 
(12 intermediate revisions by one user not shown)
Line 16: Line 16:
 
* Create nested loops to create connectivity for desired tesselation polygons (triangles, quads, etc.).
 
* Create nested loops to create connectivity for desired tesselation polygons (triangles, quads, etc.).
  
This project is due on <b>Friday, September 30th</b>. You will need to present your project in the lab starting at 2pm that day, or during one of the TA/tutors' office hours before that day.
+
This project is due on <b>Friday, September 30th</b>. You will need to present your project in the lab starting at 1:30pm that day, or during one of the TA/tutors' office hours before that day.
 +
 
 +
There will be an introductory session for this homework assignment on <b>Monday, September 26th</b> at 3pm in lab 260 (Gregory Long).
  
 
==1. Vectors and Matrices==
 
==1. Vectors and Matrices==
Line 24: Line 26:
 
===1a. Vectors (20 points, each method is one point)===
 
===1a. Vectors (20 points, each method is one point)===
  
Implement the following methods in your =Vector3= class:
+
Implement the following methods in your <tt>Vector3</tt> class:
  * Element access 'set': set the components of the vector
+
* Element access 'set': set the components of the vector
  * Element access 'get': return a specific element of the vector
+
* Element access 'get': return a specific element of the vector
  * Overload operator '[]' for 'get' access
+
* Overload operator '[]' for 'get' access
  * Vector addition
+
* Vector addition
  * Overload operator '+' for addition
+
* Overload operator '+' for addition
  * Vector subtraction
+
* Vector subtraction
  * Overload operator '-' for subtraction
+
* Overload operator '-' for subtraction
  * Multiplication with scalar
+
* Multiplication with scalar
  * Dot product
+
* Dot product
  * Cross product
+
* Cross product
  * Length
+
* Length
  * Normalize
+
* Normalize
  
Implement the following methods in your =Vector4= class:
+
Implement the following methods in your <tt>Vector4</tt> class:
 
* Element access 'set': set the components of the vector
 
* Element access 'set': set the components of the vector
 
* Element access 'get': return a specific element of the vector
 
* Element access 'get': return a specific element of the vector
Line 50: Line 52:
 
===1b. Matrices (20 points, 2 points for each method)===
 
===1b. Matrices (20 points, 2 points for each method)===
  
Implement the following methods in your =Matrix4= class:
+
Implement the following methods in your <tt>Matrix4</tt> class:
 
* Element access 'set': set the components of the matrix
 
* Element access 'set': set the components of the matrix
 
* Element access 'get': return a specific element of the matrix
 
* Element access 'get': return a specific element of the matrix
Line 64: Line 66:
 
==2. Sphere (20 points)==
 
==2. Sphere (20 points)==
  
Write a function that generates the geometry of a sphere out of simple polygons like triangles or quads. The function should create vertex coordinates (*5 points*) and colors (*5 points*). The function should take an input parameter to determine the mesh resolution, i.e., how many polygons are used to approximate the sphere (*5 points*). Use a color scheme that assigns different colors to all or at least adjacent polygons. Each polygon must be colored with a single color throughout (no color gradients within polygons).
+
Write a function that generates the geometry of a sphere out of simple polygons like triangles or quads. The function should create vertex coordinates ('''5 points''') and colors ('''5 points'''). The function should take an input parameter to determine the mesh resolution, i.e., how many polygons are used to approximate the sphere ('''5 points'''). Use a color scheme that assigns different colors to all or at least adjacent polygons. Each polygon must be colored with a single color throughout (no color gradients within polygons).
  
*Note:* The order of vertices for the triangles matters! They need to be ordered in counterclockwise orientation when seen from outside the sphere (*5 points*). If the vertices are ordered clockwise, the inside instead of the outside of the sphere will be rendered, if back face culling is enabled.
+
'''Note:''' The order of vertices for the triangles matters! They need to be ordered in counterclockwise orientation when seen from outside the sphere ('''5 points'''). If the vertices are ordered clockwise, the inside instead of the outside of the sphere will be rendered, if back face culling is enabled.
  
 
This is an example, but it is by no means the only option:
 
This is an example, but it is by no means the only option:
  
    <img src="%ATTACHURLPATH%/sphere.png" alt="sphere.png" height='394' />
+
[[Image:sphere.png]]
  
 
Note: your sphere does not need to outline the polygons, but should show the triangles in different colors.
 
Note: your sphere does not need to outline the polygons, but should show the triangles in different colors.
Line 79: Line 81:
  
 
* A car with turning "wheels" (made of boxes), moving in a circle on a ground plane.
 
* A car with turning "wheels" (made of boxes), moving in a circle on a ground plane.
* A helicopter with turning blades, flying in a circle above a ground plane.
+
* A helicopter with spinning rotor blades, flying in a circle.
 
* An industrial robot with a rotating saw, each rigid section made of a box.
 
* An industrial robot with a rotating saw, each rigid section made of a box.
 +
* The moon rotating about the earth, which rotates about the sun.
  
You will get full credit if you have an object that moves in a circle (*15 points*), and that has moving parts itself (rotating rotor blades, wheels, etc.) (*15 points*). In addition, the boxes and spheres need to be transformed (e.g., by scaling) to approximate the desired shapes (e.g., elongated rotor blades, rectangular car body) (*5 points*). To make the shapes look more interesting and distinguishable, give them or individual faces different colors (*5 points*).
+
You will get full credit if you have an object that moves in a circle ('''15 points'''), and that has moving parts itself (rotating rotor blades, wheels, etc.) ('''15 points'''). In addition, the boxes and spheres need to be transformed (e.g., by non-uniform scaling) to approximate the desired shapes (e.g., elongated rotor blades, rectangular car body) ('''5 points'''). To make the shapes look more interesting and distinguishable, give them or individual faces different colors ('''5 points''').
  
 
==4. Optional Features (up to 10 points)==
 
==4. Optional Features (up to 10 points)==
  
* Write code to generate additional geometry, for example cylinders, tori, or cones (*4 points* each).
+
* Write code to generate additional geometry, for example cylinders, tori, or cones ('''4 points''' each).
* Move objects along ellipses rather than circles (elliptical motion needs to be obvious) (*3 points*).
+
* Move objects along ellipses rather than circles (elliptical motion needs to be obvious) ('''3 points''').

Latest revision as of 21:10, 6 October 2011

Contents

Project 1: Vectors, Matrices, and Coordinate Transformations

Your project should build on the base code that we provide. You will find the code, documentation, and instructions for how to compile it here. Before you start with this project look through the documentation of the base code and get familiar with it.

This project has four parts, but only the first three 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 object that consists of several parts that move with respect to each other. In the third part you will write a function that generates cylindrical geometry.

The fourth 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 we are not going to allow the use of OpenGL or GLUT matrix routines or tesselation routines (e.g., glRotate, glTranslate, glScale, gluSphere, glutSolidCone, glutSolidTorus, glutSolidSphere, glutWireSphere) in this homework project. You need to use your own matrix routines and tesselation algorithm instead.

Defintion of Tesselation on Wikipedia: A tessellation or tiling of the plane is a collection of plane figures that fills the plane with no overlaps and no gaps.

Tesselation algorithm:

  • Find formula for position of vertices
  • Create nested loops to create all vertices.
  • Create nested loops to create connectivity for desired tesselation polygons (triangles, quads, etc.).

This project is due on Friday, September 30th. You will need to present your project in the lab starting at 1:30pm that day, or during one of the TA/tutors' office hours before that day.

There will be an introductory session for this homework assignment on Monday, September 26th at 3pm in lab 260 (Gregory Long).

1. Vectors and Matrices

Implement a basic matrix and vector library by extending the classes in the base code. You can use the C++ class shown on a lecture slide as a basis. Create separate classes for a Vector3 and a Vector4 type, with three or four components, respectively. The matrix class should be for 4x4 matrices.

1a. Vectors (20 points, each method is one point)

Implement the following methods in your Vector3 class:

  • Element access 'set': set the components of the vector
  • Element access 'get': return a specific element of the vector
  • Overload operator '[]' for 'get' access
  • Vector addition
  • Overload operator '+' for addition
  • Vector subtraction
  • Overload operator '-' for subtraction
  • Multiplication with scalar
  • Dot product
  • Cross product
  • Length
  • Normalize

Implement the following methods in your Vector4 class:

  • Element access 'set': set the components of the vector
  • Element access 'get': return a specific element of the vector
  • Overload operator '[]' for 'get' access
  • Vector addition
  • Overload operator '+' for addition
  • Vector subtraction
  • Overload operator '-' for subtraction
  • Dehomogenize (make fourth component equal to 1)

1b. Matrices (20 points, 2 points for each method)

Implement the following methods in your Matrix4 class:

  • Element access 'set': set the components of the matrix
  • Element access 'get': return a specific element of the matrix
  • Multiply (matrix-times-matrix)
  • Multiply (matrix-times-vector): implement separate routines for multiplication with Vector3 and Vector4. You should promote a Vector3 to a Vector4, and then dehomogenize after the multiplication and return a Vector3.
  • Make rotation matrix about x axis
  • Make rotation matrix about y axis
  • Make rotation matrix about z axis
  • Make rotation matrix about arbitrary (unit) axis
  • Make non-uniform scaling matrix
  • Make translation matrix

2. Sphere (20 points)

Write a function that generates the geometry of a sphere out of simple polygons like triangles or quads. The function should create vertex coordinates (5 points) and colors (5 points). The function should take an input parameter to determine the mesh resolution, i.e., how many polygons are used to approximate the sphere (5 points). Use a color scheme that assigns different colors to all or at least adjacent polygons. Each polygon must be colored with a single color throughout (no color gradients within polygons).

Note: The order of vertices for the triangles matters! They need to be ordered in counterclockwise orientation when seen from outside the sphere (5 points). If the vertices are ordered clockwise, the inside instead of the outside of the sphere will be rendered, if back face culling is enabled.

This is an example, but it is by no means the only option:

Sphere.png

Note: your sphere does not need to outline the polygons, but should show the triangles in different colors.

3. Animated Object (40 points)

Construct an animated object that consists of at least three parts. You can use simple boxes and transform them appropriately. Use at least one sphere in the model which you construct with the algorithm from part 2. Make an animation where at least three parts move with respect to each other. For example:

  • A car with turning "wheels" (made of boxes), moving in a circle on a ground plane.
  • A helicopter with spinning rotor blades, flying in a circle.
  • An industrial robot with a rotating saw, each rigid section made of a box.
  • The moon rotating about the earth, which rotates about the sun.

You will get full credit if you have an object that moves in a circle (15 points), and that has moving parts itself (rotating rotor blades, wheels, etc.) (15 points). In addition, the boxes and spheres need to be transformed (e.g., by non-uniform scaling) to approximate the desired shapes (e.g., elongated rotor blades, rectangular car body) (5 points). To make the shapes look more interesting and distinguishable, give them or individual faces different colors (5 points).

4. Optional Features (up to 10 points)

  • Write code to generate additional geometry, for example cylinders, tori, or cones (4 points each).
  • Move objects along ellipses rather than circles (elliptical motion needs to be obvious) (3 points).