Wednesday, June 19, 2019

Clipping in computer graphics


The primary use of clipping in computer graphics is to remove object, Lines or lines segments that are outside the view pane. The viewing transformation ins insensitive to the position of points relative to the viewing volume specially those points behind the viewer, it is necessary these points before generating the view.

Types of Clipping: -

     1. Point Clipping: - Clipping a point from a given window is simple consider the accompanying figure where the square shape shows the window point cutting discloses to us whether we will use the minimum & maximum coordinates of the window

Clipping in computer graphics
The x coordinate at the given point is inside the window then x lies in between Wx1 and Wx2
                Wx1 =< x =< Wx2
For y coordinate    
                                Wy1 =< y =< Wy2

     1.       Line Clipping: - It is the concept of line clipping is same as point clipping.In line clipping we will cut the part of line which is outside of window and keep just the segment that is inside the window.

     2.       Cohen- Sutherland line Clipping: - This algorithm user the clipping window as shown in the following figure. The minimum coordinate for the clipping region is (Xwmin , Ywmin) & the maximum coordinate for the clipping region is (Xwmax , Ywmax)

 Cohen- Sutherland line Clipping

We will use four bits to divide the entire Region. These 4 bits represent the top bottom region here the top and left corner.
1.       There are three possibilities for the line can be completely inside the window.
2.       Line can be completely outside the window.
3.       Line can be partially inside the window.
Algorithm: -

        1.       Assign a region code for each point.
        2.       If both end points have a region code 0000 than accept this line.
        3.       Else present the logical AND operation for both region code.
        4.       If the result is not 0000 than result the line else you need clipping.
        5.       Choose an end point of the line that is outside the window.
        6.       Find the intersection point at the window Boundary based on the region code.
        7.       Replace end point with the intersection point and update the region code.
        8.       Repeat step 5 until we find a clipping line either accepted or a rejected.
        9.       Repeat step once 1 for other line.

No comments:

Post a Comment