CSCI 480/580 Lecture 24 - In-Class Problems

 

Let's suppose, without loss of generality, that we're looking to clip a triangle against the plane. We can develop a solution for this and generalize it to handle the other five clipping planes.

We saw that there are 4 cases we need to handle:

  1. all in (keep the triangle)
  2. all out (discard the triangle)
  3. one in, two out (create one clipped triangle)
  4. two in, one out (create two clipped triangles)

Case 4 is illustrated here:

  1. Given three vertices , write pseudocode to decide which of the above cases applies to a given triangle when clipping against the plane.
  2. Write pseudocode to produce the vertices of of the new triangle resulting from the case 2 ("one in, two out").
  3. Write pseudocode to produce the vertices and of the two new triangles resulting from the case 4 ("one in, two out").