Asg 4: Compute face normals and face centers for each face of the a AW object that holds the points and faces lists

Objectives

In its own aw.py module, set up a AW object (class) that it now contains the object's data: Provide object methods to which get called immediately after the object is read in and the file that contained the object data is closed (at the end of the read(self,filename) method. Thse methods are only called once.

Assignment

  1. Compute each face center as the average of all of the face's verteces, i.e.,
    \[ \mathbf{C} = \frac{1}{n}\sum_{i=1}^{n}{\mathbf{v}_i} \]
  2. Compute each face normal as the cross product of two vectors on the face, e.g.,
    \[ \mathbf{N} = \frac{\left(\mathbf{v}_2 - \mathbf{v}_1\right) \times \left(\mathbf{v}_n - \mathbf{v}_1\right)} {\|\left(\mathbf{v}_2 - \mathbf{v}_1\right)\| \|\left(\mathbf{v}_n - \mathbf{v}_1\right)\|} \]
  3. For each face, draw the face normal as a line from the face center that is some small (e.g., 0.5) distance along the face normal, i.e.,
    \[ \mathbf{P} = \mathbf{C} + c \mathbf{N} \]

Details

  1. For computation of the normal, use temporary vector variables (an np.array([0,0,0])) A and B and then compute the cross produce with n = np.cross(A,B) using numpy.
  2. The point that is located some distance along the normal vector can be made local to the draw(self) method. With two local variables center and normal, the point along the vector is computed as
          point = center + c * normal
    	
  3. Remember that there are as many face normals and face centers as there are faces.
  4. To draw the normal, use GL_LINES, e.g.,
          glBegin(GL_LINES)
          glVertex3f(center[0], center[1], center[2])
          glVertex3f(point[0], point[1], point[2])
          glEnd()
    	

Requirements

  1. Use the cube-ccw.obj to read in and test with (include it in your assignment).

Turn in

Turn in all of your code, in one tar.gz archive of your asg##/ directory, including:
  1. A README file containing
    1. Course id--section no
    2. Name
    3. Brief solution description (e.g., program design, description of algorithm, etc., however appropriate).
    4. Lessons learned, identified interesting features of your program
    5. Any special usage instructions
  2. source code (.py source)

How to hand in

See handin web page

Grading scheme