3D Clipping
3D clipping is required when displaying 3D objects that can have negative z values when transformed to world space. Consider again our 40x40x40 cube. If we assume the cube vertices are defined in world space instead of object space, the cube will be drawn centred at the world space origin. This means the front half of the cube will extend through z=0 and into negative z space. This will cause major problems when we project the world space points to screen space when displaying the cube.
3D clipping solves this problem by clipping a polygon's world space points against a specified z plane, called the near clipping plane. Any z coordinates that extend into this plane are set to the near clipping value, and their x and y coordinates are adjusted accordingly. Besides the near clipping plane, 3D clipping also supports a far clipping plane. Objects that are completely behind the far clipping plane are not drawn, as we assume these are too far away for the viewer to see., a near clipping value of 1 and a far clipping value of 1000, but we can redefine these with Its two parameters are floating point z values that respectively specify the near and far clipping planes. They must be greater than zero (recall that z values are positive in a left-handed 3D coordinate system), or if z-buffering is used, greater than or equal to 1. The far clipping plane must be greater than the near clipping plane.
We must also use 3D clipping when we use a different POV. In this case, any transformed z coordinates that end up behind the viewer must be clipped. Although this might seem like a special case at first, it's really just analogous to clipping negative z values when using the default POV.
Cohen-Sutherland 3D line clipping algorithm
Cyrus-Back 3D line Clipping algorithm
Cyrus Beck is a line clipping algorithm that is made for convex polygons. It allows line clipping for non-rectangular windows, unlike Cohen Sutherland or Nicholl Le Nicholl. It also removes the repeated clipping needed in Cohen Sutherland.
Algorithm:
- Normal of every edge is calculated.
- Vector for the clipping line is calculated.
- Dot product between the difference of one vertex per edge and one selected end point of the clipping line and the normal of the edge is calculated (for all edges).
- Dot product between the vector of the clipping line and the normal of edge (for all edges) is calculated.
- The former dot product is divided by the latter dot product and multiplied by -1. This is ‘t’.
- The values of ‘t’ are classified as entering or exiting (from all edges) by observing their denominators (latter dot product).
- One value of ‘t’ is chosen from each group, and put into the parametric form of a line to calculate the coordinates.
- If the entering ‘t’ value is greater than the exiting ‘t’ value, then the clipping line is rejected.
- Case 1: The line is partially inside the clipping window:
- 0 <tE<tL< 1
- where tE is 't' value for entering intersection point
- tL is 't' value for exiting intersection point
- Case 2: The line has one point inside or both sides inside the window or the intersection points are on the end points of the line:
0 ≤ tE ≤ tL ≤ 1
- Case 3: The line is completely outside the window:
tL<tE
0 Comments