CS121 Project 2

Collision Detection Overview



The collision detection algorithm takes as input the endpoints of the ball's path, p0 and p1, the ball's radius r, and a description of the triangles in the scene. The algorithm returns the fraction, α in [0,1], of the path the ball can travel before it collides with a triangle. If no collision occurs along the path the algorithm returns α=1. When the algorithm detects a collision before the end of the path, it also returns the surface normal at the point of collision.

To simplify the collision detection algorithm, we will ignore collisions with the back faces of triangles. Since we have agreed to use closed surfaces, a collision with the back face of a triangle must be preceeded by a front-face collision!

In addition, we want to distinguish between the cases when the ball collides with a triangle and when it is simply touching one. This is important, for example, so we can allow the ball to roll across a triangle. Our definition then is that the ball collides with a triangle if

  1. It touches the triangle, i.e. it has a point in common with the triangle, and
  2. It is moving toward the triangle, i.e. the ball's velocity vector and the forward facing normal of the triangle have a negative dot product.

A ball can collide with a triangle's face, edge, or vertex. There are individual tests for each of these case. Details are described in separate notes; face, edge, and vertex.

If we perform collision detection on a triangle by triangle basis, then shared edges will be tested twice and shared vertices will be tested once for each incident triangle. To avoid repeating tests, we can represent our triangles by lists of unique vertices, edges, and faces, where where each edge and face record has pointers to its incident vertices in the vertex list.

Assuming this data structure, the collision detection algorithm simply steps through the vertex, edge, and face lists, calling the appropriate detection algorithm for each primitive and remembering the time of the earliest collision. It is possible for the ball to collide simultaneously with more than one primitive. In this case the collision detection algorithm returns the average of the surface normals at the collision points.

Important Notes


Last updated 2/26/04