Ax + By + Cz + D = F(x,y,z)
F(x,y,z)=0 for points on the plane
This can be rewritten as:
F(P) = N.P + D
Plane(s,t) = P0 + s(P1-P0) + t(P2-P0), provided P0, P1, and P2 are non-colinear.
Plane(s,t) = P0 + s V1 + t V2, where V1 and V2 are two basis vectors.
Both the Cohen-Sutherland line-clipping algorithm and the Sutherland-Hodgman polygon-clipping algorithm can be extended to 3D. We could choose to perform clipping in any one of VCS, CCS, or NDCS. As we shall explain shortly, there is a shortcoming to clipping in NDCS.
left: x - left = 0 right: -x + right = 0 bottom: y - bottom = 0 top: -y + top = 0 front: -z - near = 0 back: z + far = 0The same can also be done for the perspective view volume:
left: x + left*z/near = 0 right: -x - right*z/near = 0 top: -y - top*z/near = 0 bottom: y + bottom*z/near = 0 front: -z - near = 0 back: z + far = 0The Cohen-Sutherland clipping procedure works exactly the same in 3D as it does in 2D. Vertex outcodes are generated and tested for a trivial accept or reject. If there is no trivial accept or reject, the line is clipped against one if the six view-volume planes, then tested again, and so on.
The Sutherland-Hodgman polygon clipping algorithm also works in a similar way. The polygon can be clipped against the six view-volume planes in succession.
The potential problem of clipping in NDCS is that the sign of the depth information is lost, as shown in the following example.
This can be visualized as follows:
The clipping regions are analogous for y and z. The following example illustrates clipping in CCS.