# Clipping

The clipping process eliminates invisible faces from rendering process but also reduces the partially visible faces.

Both are made in 2D projection plane and 3D camera space. With projection plane we can eliminate and reduce polygons along X and Y axis. But the job is a blittle bit harder for depth clipping, this is why I will discuss a few about that point.

Z clipping is realized in 3D camera space, the picture below illustrates a polygons that is partially outside the 2D projection plane (the part A is visible but not the part B).

So, we have to test which vertices have a Z coordinate (depth) lower than the projection plane depth (defined in camera space).

Then we clip each edge using linear interpolation along Z axis.

As we consider only triangular polygons, we only have four cases:

1None the of vertices have a Z coordinate lower than projection plane depth

2One vertex has got a Z coordinate lower than projection plane depth

- Clip each edge sharing the vertex outside the projection plane, using linear interpolation.
- Add a new edge into the left or right edge table (that needs sorting).

3Two vertices have got a Z coordinate lower than projection plane depth

We have to clip each edge having vertex outside the projection plane, using linear interpolation as described above.

4All vertices have got a Z coordinate lower than projection plane depth

The polygon is not considered as visible, it isn't drawn.