Clipping

We want to portions of objects outside the view frustrum (boundaries of the image plane projected into 3D). This is defined in terms of 6 planes (including a near & far plane). Clipping avoids degeneracy and improves efficiency.

1. When to Clip?

2. Halfspaces

A halfspace is defined by a plane. The plane divides space into two halfspaces. A point is inside the halfspace if it is on the plane or on the "inside" side of the plane.

A plane equation is , defined with a normal vector in homogeneous coordinates. Each point has an infinite number of equivalent homogeneous coordianates, which relates to the infinite number of equivalent plane equations:

2.1 Point to Plane Distance

We can scale such that is normalised. Then distance is easily calculated as . is a signed distance, positive if is in the halfspace, negative otherwise.

When clipping, we don't need to normalize, but we will get an incorrect magnitude for .

3. Clipping with View Frustrum

So, we test against each of the 6 planes ofn the view frustrum. Here:

4. Clipping Lines

To intersect a line & plane, we use the parametric line euqation . For example:

  1. For any vector in the plane , let the intersection point be .
  2. A vector in that plane is given by .
  3. So, .
  4. Solve for and find the point of intersection.

Take two points either side of the plane that make a line, and . Then:

These operations are implemented in hardware, so we don't need to worry about efficiency.

5. Clipping Objects

Clipping can be carried out against any objects. We can develop containment tests for convex objects (common problem, e.g. convex polyhedra) and concave objects.

5.1 Convex Objects

A convex object satisfies:

To test if an object is convex:

1convex = true; 2for each face F of object { 3 find plane equation of face: F(x,y,z) = 0; 4 choose point (x_i,y_i,z_i) not on the face; 5 6 for all other points of the object { 7 if (sign(F(x_i,y_i,z_i)) != sign(F(x,y,z))) { 8 convex = false; 9 break; 10 } 11 } 12}

The same test can be expressed in vector form, avoiding the need to calculate the Cartesian equation of our plane. To do this, we store normal vector for each face of our object: is inside of the face if is acute, , or , where is any point on the face.

To find the normal vector of a face, we can take the cross prouct of two edges of the face (or any vector in the plane).


We must take care to ensure the normal vector points outwards from the object. We can do this by ensuring the vertices of the face are ordered counter-clockwise when viewed from outside the object.


To check this direction, we need to look at the rest of the object.

5.2 Concave Objects

Containment and clipping for concave objects uses the ray containment test. This works by finding all intersections between a ray and polygon edges (faces). If the number of intersections is odd, the point is contained.

To calculate intersections, we define a ray as , . We can choose any . Solve intersection for and . The intersection is valid if and . This extends to 3D:

  1. Compute the intersection of the ray with the plane of each face.
  2. If , check whether the intersection point is contained in the face (not trivial, but can be reduced to 2D under orthographic projection).

To clip to concave volumes, we may need to split the lines & volumes into segments & concave parts. Usually, concave volumes are unused.

Back to Home