0
4.4kviews
State what is meant by clipping. Explain any one clipping algorithm.

Mumbai university > Comp > SEM 4 > Computer Graphics

Marks: 5M

Year: Dec 2015

1 Answer
0
58views
  • A polygon can also be clipped by specifying the clipping window.

  • The primary use of clipping in computer graphics is to remove objects, lines, or line segments that are outside the viewing pane.

  • The viewing transformation is insensitive to the position of points relative to the viewing volume especially those points behind the viewer and it is necessary to remove these points before generating the view.

  • Sutherland Hodgeman polygon clipping algorithm is used for polygon clipping.

  • In this algorithm, all the vertices of the polygon are clipped against each edge of the clipping window.

Cohen-Sutherland Line Clippings:

  • This algorithm uses the clipping window as shown in the following figure.

  • The minimum coordinate for the clipping region is $(XW_{min}, YW_{min})$ $(XW_{min}, YW_{min})$ and the maximum coordinate for the clipping region is $(XW_{max}, YW_{max})$ $(XW_{max}, YW_{max})$.

enter image description here

  • We will use 4-bits to divide the entire region.

  • These 4 bits represent the Top, Bottom, Right, and Left of the region as shown in the following figure.

  • Here, the TOP and LEFT bit is set to 1 because it is the TOP-LEFT corner.

enter image description here

  • There are 3 possibilities for the line −

    • Line can be completely inside the window (This line will be completely removed from the region).

    • Line can be completely outside of the window (This line will be completely removed from the region).

    • Line can be partially inside the window (We will find intersection point and draw only that portion of line that is inside region).

  • Algorithm

    Step 1 − Assign a region code for each endpoints.

    Step 2 − If both endpoints have a region code 0000 then accept this line.

    Step 3 − Else, perform the logical AND operation for both region codes.

    Step 3.1 − If the result is not 0000, then reject the line.

    Step 3.2 − Else you need clipping.

    Step 3.2.1 − Choose an endpoint of the line that is outside the window.

    Step 3.2.2 − Find the intersection point at the window boundary (base on region code).

    Step 3.2.3 − Replace endpoint with the intersection point and update the region code.

    Step 3.2.4 − Repeat step 2 until we find a clipped line either trivially accepted or trivially rejected.

    Step 4 − Repeat step 1 for other lines.

Please log in to add an answer.