To push the 1 to 0, we clip against the boundary line x min=-3. The candidates for clipping are AB, CD, and GH. We place the line segments in their appropriate categories by testing the region codes found in the problem.Ĭategory1 (visible): EF since the region code for both endpoints is 0000.Ĭategory2 (not visible): IJ since (1001) AND (1000) =1000 (which is not 0000).Ĭategory 3 (candidate for clipping): AB since (0001) AND (1000) = 0000, CD since (0000) AND (1010) =0000, and GH. The region code for point (x, y) is set according to the schemeīit 1 = sign (y-y max)=sign (y-6) Bit 3 = sign (x-x max)= sign (x-2)īit 2 = sign (y min-y)=sign(1-y) Bit 4 = sign (x min-x)=sign(-3-x) Find the region codes for the endpoints in fig: Let R be the rectangular window whose lower left-hand corner is at L (-3, 1) and upper right-hand corner is at R (2, 6). Y wmax is the maximum value of Y co-ordinate of the window Example of Cohen-Sutherland Line Clipping Algorithm: (d) If bit 4 is "1" line intersects with the top boundary Y wmin is the minimum value of Y co-ordinate of the window (c) If bit 3 is "1" line intersects with bottom boundary Where X more is maximum value of X co-ordinate of the window (b) If bit 2 is "1" line intersect with right boundary Where X wminis the minimum value of X co-ordinate of window (a) If bit 1 is "1" line intersects with left boundary of rectangle window Step4:If a line is clipped case, find an intersection with boundaries of the window Step2:Perform OR operation on both of these end-points Step1:Calculate positions of both endpoints of the line It can clip pictures much large than screen size.Īlgorithm of Cohen Sutherland Line Clipping:.It calculates end-points very quickly and rejects and accepts lines quickly.Line CD are clipping candidate Advantage of Cohen Sutherland Line Clipping: The center area is having the code, 0000, i.e., region 5 is considered a rectangle window.įollowing figure show lines of various types If both endpoints of the line have end bits zero, then the line is considered to be visible. First of all, the category of a line is found based on nine regions given below. Clipping Case: If the line is neither visible case nor invisible case. Y min,y max are also coordinates of the window.ģ. X min,x max are coordinates of the window. Let A (x 1,y 2) and B (x 2,y 2) are endpoints of line. If any one of the following inequalities is satisfied, then the line is considered invisible. Not Visible: If a line lies outside the window it will be invisible and rejected. A line is visible and will be displayed as it is.Ģ. Visible: If a line lies within the window, i.e., both endpoints of the line lies within the window. All lines come under any one of the following categories:ġ. In the algorithm, first of all, it is detected whether line lies inside the screen or it is outside the screen. Midpoint Subdivision Line Clipping AlgorithmĬohen Sutherland Line Clipping Algorithm:.Cohen Sutherland Line Clipping Algorithm.It is performed by using the line clipping algorithm.
0 Comments
Leave a Reply. |