Cohen Sutherland Algorithm is a line clipping algorithm that cuts lines to portions which are within a rectangular area. It eliminates the lines from a given set of lines and rectangle area of interest view port which belongs outside the area of interest and clip those lines which are partially inside the area of interest. The algorithm divides a two-dimensional space into 9 regions eight outside regions and one inside region and then efficiently determines the lines and portions of lines that are visible in the central region of interest the viewport. The more efficient Cohen-Sutherland Algorithm performs initial tests on a line to determine whether intersection calculations can be avoided. What is the limitation of Cohen Sutherland algorithm?
|Published (Last):||26 June 2019|
|PDF File Size:||18.87 Mb|
|ePub File Size:||10.70 Mb|
|Price:||Free* [*Free Regsitration Required]|
The Cohen—Sutherland algorithm is a computer-graphics algorithm used for line clipping. The algorithm divides a two-dimensional space into 9 regions and then efficiently determines the lines and portions of lines that are visible in the central region of interest the viewport. The algorithm was developed in during flight-simulator work by Danny Cohen and Ivan Sutherland. The numbers in the figure below are called outcodes. An outcode is computed for each of the two points in the line. The outcode will have 4 bits for two-dimensional clipping, or 6 bits in the three-dimensional case.
The first bit is set to 1 if the point is above the viewport. The bits in the 2D outcode represent: top, bottom, right, left. For example, the outcode represents a point that is top-right of the viewport.
Note that the outcodes for endpoints must be recalculated on each iteration after the clipping occurs. The Cohen—Sutherland algorithm can be used only on a rectangular clip window. From Wikipedia, the free encyclopedia. Categories : Line clipping algorithms.
Cohen Sutherland Line Clipping Algorithm
In the algorithm, first of all, it is detected whether line lies inside the screen or it is outside the screen. All lines come under any one of the following categories:. Visible: If a line lies within the window, i. A line is visible and will be displayed as it is. Not Visible: If a line lies outside the window it will be invisible and rejected. Such lines will not display.
Given a set of lines and a rectangular area of interest, the task is to remove lines which are outside the area of interest and clip the lines which are partially inside the area. Cohen-Sutherland algorithm divides a two-dimensional space into 9 regions and then efficiently determines the lines and portions of lines that are inside the given rectangular area. The Cohen—Sutherland algorithm can be used only on a rectangular clip window. For other convex polygon clipping windows, Cyrus—Beck algorithm is used. We will be discussing Cyrus—Beck Algorithm in next set. This article is contributed by Saket Modi.
Cohen-Sutherland Line Clipping The Cohen-Sutherland line clipping algorithm quickly detects and dispenses with two common and trivial cases. To clip a line, we need to consider only its endpoints. If both endpoints of a line lie inside the window, the entire line lies inside the window. It is trivially accepted and needs no clipping. On the other hand, if both endpoints of a line lie entirely to one side of the window, the line must lie entirely outside of the window. It is trivially rejected and needs to be neither clipped nor displayed.