# CS488 - Introduction to Computer Graphics - Lecture 21

1. Exam: April 16th, 2008, 09.00, RCH???

# 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 points: three floating point numbers
2. Array of edges: pair of pointers to vertices
3. Array of faces: pointers to the vertices at the corners
4. Build the arrays as you read the input.

Now let's think about modifying the mesh.

1. Add a vertex, given its coordinates
• Easy

Is this vertex already in the data structure?

• Hmmm?

Keep the vertices sorted by location

2. Delete a vertex, including edges and faces
• Leave them dangling?
• You had better not do much deleting

Finding the edges and faces is not easy

• Add pointers from vertices to edges and faces

What about the hole in the vertex array?

3. Add an edge, given two vertices
• Easy

Is the edge already in the data structure?

• How would you find out?
4. Delete an edge, including possible faces and disconnected points.
• Edge is easy
• Finding vertices is easy.
• Are they disconnected

Are any faces affected?

5. Split a face with a new vertex, given face, vertex
• Adding the vertex is easy

Delete the old face

• Idea. Overwrite the old face with one of the new ones

In summary we have,

1. Each vertex has pointers to two edges
2. Each vertex has pointers to n faces
3. Each edge has pointers to two faces

#### Winged Edge Data Structure

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

• edges are vertex pairs,
• faces are vertex n-tuples n>2.

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

• not just any graphs but ones that obey constraints
• for every constraint there is an invariant
• complete sets of invariants are not known: not for lack of trying to find them

Every time we see a graph we should think,

In the dual edges are primary:

• vertices are where edges meet,
• faces are minimal closed paths

Winged edge data structure

• Where does the name come from?

Each edge has

1. pointers to the faces it separates
2. pointers to the vertices at its ends
3. participates in a doubly linked list of edges at each of its ends

Each vertx has

1. one pointer to an edge
2. Exercise. Why do you only need one?

Each face has

1. one pointer to an edge
2. Exercise. Why do you only need one?

Issues to consider

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?

# Animation

## Motion

Quite simple, really

• Parameters of the model are functions of time.
• parameters of moving objects
• parameters of camera, including things like depth of field
• The modeller (or the interface) must specify these functions.
• Constraints.
• The functions must be physically `realistic'.
• The functions must be easily specifiable.

`Specifiable': Think splines.

`Realistic': Think continuity.

1. C0 continuity: no teleportation, possible discontinuities in velocity, which violate Newtonian mechanics.
2. C1 continuity: no discontinuities in velocity, possible infinite accelarations.
3. C2 continuitiy: acceleration continuous, possible infinite jerks.
4. etc.

#### Definition of `realistic' varies

1. Between camera and actors

As type of actor changes: compare classic Disney animation to live action, which obeys Newtonian dynamics (and other constraints, too)

## Spline Curves

#### Affine Combinations

1. Line segments
• Two points
• P^1_0(t, u) = uP0 + tP1
• For this to be affine we need u + t = 1
• Three points
• P^1_0(t, u) = uP0 + tP1; P^1_1(t, u) = uP1 + tP2
• P^2_0(t, u) = uP^1_0(t, u) + tP^1_1(t, u) = u^2 P0 + 2ut P1 + t^2 P2
• Notice derivatives at end points are not independent
3. Cubic segments
• Four points
• P^3_0(t, u) = t^3 P0 + 3t^2 u P1 + 3 t u^2 P2 + u^3 P3
• Now the derivatives at the end points are independent
4. etc

This process is called `blending' points.

If we call comb(n,i)u^(n-i) t^i the Bernstein polynomial, B(n, i; t, u), then

• The n'th degree segment is
• sum_i B(n, i; t, u) Pi is the blend
• This is a Bezier curve of degree n.
• Pi: i = 0,...,n are the control points.
• Note. n is not the dimension of the space in which you are working.
• Useful fact:
• sum_i B(n, i; t, u) = (t + u)^n = 1.
• The sum in the blend is necessarily affine (Why is this important?)
• This should remind us strongly of all the stuff we know about binomials: Pascal's triangle and all that.

#### Joining Bezier curves

With C0 continuity

• Q0 = P3
• Interface
1. Place P0, P1, P2, P3
2. Q0 is determined; place Q1, Q2, Q3
3. R0 is determined; place R1, R2, R3
4. etc.

With C1 continuity

• Q0 = P3
• Q1 - Q0 = P3 - P2, or Q1 = 2 P3 - P2
• Interface
1. Place P0, P1, P2, P3
2. Q0, Q1 are determined; place Q2, Q3
3. R0, R1 are determined; place R2, R3
4. etc.

Weaker first order continuity G1

• Q0 = P3
• Q1 - Q0 = a(P3 - P2), or Q1 = (a+1) P3 - a P2 a > 0 (Why?)
• Interface
1. Place P0, P1, P2, P3
2. Q0 is determined; choose a, place Q2, Q3
3. R0 is determined; choose b, place R2, R3
4. etc.

With C2 continuity

• Q0 = P3
• Q1 - Q0 = P3 - P2, or Q1 = 2 P3 - P2
• Q2 = linear combination of P1, P2, P3 (Calculation an exercise for the reader.)

Interface

1. Place P0, P1, P2, P3
2. Q0, Q1, Q2 are determined, place Q3

etc.