CS488 - Introduction to Computer Graphics - Lecture 30


Polyhedra and Meshes

What is a polyhedron?

  1. A set of vertices
  2. Connected by edges
  3. Which define faces

Ray Tracer format

  1. Array of vertices (3 floats)
  2. Array of faces (pointers to vertices, needs to know number of vertices)
  3. Build the arrays as you read the input.

Ray tracer requires intersection tests, normal calculation.

What does the ray tracer format give?

  1. Intersect a line with a plane
  2. Normal calculation requires three consecutive vertices


  1. Finding the faces that surround a vertex, or the edges that emanate from a vertex
  2. Modifying the mesh.
    1. Add a vertex and a face
      • easy because the user must specify the three vertices
      • add the new vertex
      • add the new face
    2. Add a vertex, split a face, need to find the face.
      • user specifies face (O(# of faces)) & new vertex
      • add new vertex
      • overwrite old face
      • add two new faces
    3. Deleting a face. ( O(# of faces))
    4. Splitting or deleting a vertex
      • Need to find the faces that surround a vertex.

Augmented Ray Tracer Format

  1. Build a list of faces for each vertex when reading the input
  2. Can now find faces from vertices. To split a vertex
  3. General deletion is still hard, unless you are willing to tolerate holes in the array.

Winged Edge Data Structure

When we talk about polyhedra & meshes it seems most natural to talk about vertices

And we have been most interested in vertices and faces. Meshes are, of course, graphs

Every time we see a graph we should think,

In the dual edges are primary:

Operations we want to do

  1. Faces that are neighbours of a vertex
  2. Faces that are neighbours of a face
  3. Vertices that are neighbours of a vertex
  4. Vertices that are neighbours of a face
  5. Modify the polyhedron
    1. Move a vertex
    2. Add a vertex, plus edges and faces
    3. Add an edge between two vertices, plus faces
    4. Delete various stuff, including disconnected vertices

Winged edge data structure

Each edge has

  1. pointers to the faces it separates
  2. pointers to the vertices at its ends
  3. pointers to the next and previous edges at each vertex
  4. struct edge {
       struct vert* v1, v2;
       struct edge* nxt1, nxt2, prv1, prv2;
       struct face* f1, f2;

Each vertex has

  1. one pointer to an edge
  2. Exercise. Why do you only need one?
  3. struct vert {
       struct *edge rep;

Each face has

  1. one pointer to an edge
  2. Exercise. Why do you only need one?
  3. struct face {
       struct *edge rep;

Note. Data suppressed in the above data structures.

Exercises for the reader: Write C code that demonstrates the following.

  1. Traversal. Can you find all neighbours quickly?
  2. Vertex/edge addition. Can you do it in constant time?
  3. Vertex/edge deletion. Can you do it in constant time?

Splines without Tears (or Jerks)

Why do splines exist at all?

General piece-wise curves

  1. One example is line segments: you have been making them all along.

When you put them in a mesh there is an extra requirement

For linear splines

  1. Blending is the key operation.
  2. Start with two points P1, P2
  3. Get the in-between points using P(t) = P1 + t(P2 - P1) for 0<t<1.

Linear curves necessarily give derivative discontinuities (called C1 continuity)

We can make the discontinuities unimportant by putting the points close enough together

The usual way is a piecewise continuous non-linear curve, with as much continuitity as you desire at the joins.

Non-linear blending

  1. Start with three points P1, P2, P3
  2. Blend in pairs
  3. Blend the blend
  4. The result is a quadratic curve

You can take this to as many levels as you want. What does it give you? Continuity. Which is?

Now you have a way of making smooth-enough curves specified by a small number of points.

Why is it important to have them available?

Return to: