Header Ads Widget

3D Clipping

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

1. The Cohen Sutherland algorithm extends easily to 3D. It extends the
3D clipping window boundaries to define 27 regions. Assign a 6 bit codeto each region, that is, for each point (x,y,z).
2. Suppose the bands for cuboid view volume are (X min, X ma2), (Ymin ,  Ymax)
and (Zmin, Zmax) where the subscript vmin and vmax stands for view
volume min limit and view volume max limit (front and back end planes).
We assign bit codes to any point (x, y, z) as :


Bit1 = 1 if x <Xmin
Bit 2 = 1 if x >Xmax
Bit 3 = 1 ify <Ymin
Bit 4 =1 if y >Ymax
Bit 5 = 1 ifz<Zmin
Bit 6 =1 if z>Zmax
Otherwise bits are set to 0 (zero).
4.  A point is inside if the region code is 000000. Therefore a line is visible ifboth ends are 000000
5.A line is invisible if it lies entirely to one side of the clipping region, thatis, if logical AND operation on the bit codes of the end points is non-zero.

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.
  1. Case 1: The line is partially inside the clipping window:
  2. 0 <tE<tL< 1
  3.  
  4. where tE is 't' value for entering intersection point
  5. tL is 't' value for exiting intersection point
  6. 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

  1. Case 3: The line is completely outside the window:

tL<tE

Post a Comment

0 Comments