Cohen-Sutherland Line Clipping Algorithm: When drawing a 2D line on screen, it might happen that one or both of the endpoints are outside. The primary use of clipping in computer graphics is to remove objects, lines, or line This algorithm is more efficient than Cohen-Sutherland algorithm. Department of Computing Science, Umeå University. Computer Graphics & Visualization. Overview. Clipping. ▫ Cohen-Sutherland line clipping algorithm.

Author: Kebei Akir
Country: Anguilla
Language: English (Spanish)
Genre: Love
Published (Last): 22 February 2009
Pages: 337
PDF File Size: 16.47 Mb
ePub File Size: 20.53 Mb
ISBN: 692-9-57307-841-4
Downloads: 2354
Price: Free* [*Free Regsitration Required]
Uploader: Tojadal

In this type of graphics, sutherlane are stored bit by bit and hence it is named Bit-map graphics. An outcode is computed for each of the two points in the line.

You can connect with him on facebook. As you proceed around the window, extending compuetr edge and defining an inside half-space and an outside half-space, nine regions algoritjm created – the eight “outside” regions and the one “inside”region. 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.

If the region is to the left of the window, the first bit of the code is set to 1. For better understanding let us consider the following example where we draw a smiley face using bit-map graphics.

The concept of line clipping is same as point clipping. For example, the outcode represents a point that is top-right of the viewport.


The Cohen—Sutherland algorithm can be used only on a rectangular clip window. The line segment’s endpoints are tested to see if the line can be trivally accepted or rejected. It is a type of computer graphics that the computer uses to store and display pictures.

Each bit position indicates a direction, starting from the rightmost position of each bit indicates left, right, bottom, top respectively. PT setcode PT p.

Cohen–Sutherland algorithm – Wikipedia

The bits in the 2D outcode represent: In line clipping, we will cut the portion of line which is outside of window and keep only the portion that is inside the window. Each end point of the line segment is then assigned the code sutherlamd the region in which it lies. By using this site, you agree to the Terms of Use and Privacy Policy.

Reject line segment if any end point of line appears outside of any compiter. In this method if the string is entirely inside the clipping window, then cohenn keep it.

Once the codes for each endpoint of a line are determined, the logical AND operation of the codes determines if the line is completely outside of the window. This clipping method is based on characters rather than the entire string. If both codes arebitwise OR of the codes yields line lies completely inside the window: To determine whether endpoints are inside or outside a window, the algorithm sets up a half-space code for each endpoint.

If the character is on the boundary of the clipping window, then we discard that entire character and keep the rest suthedland. Various techniques are used to provide text clipping in a computer graphics.


For example, if the endpoint codes are andthe logical OR is – the line can be trivally accepted. Line can be completely outside of the window This line will be completely removed from the region.

First the polygon is clipped against the left edge of the polygon window to get ggaphics vertices of the polygon. In this algorithm, all the vertices of the polygon are clipped against each edge of the clipping window. These codes identify location of the end point of line. Consider the following figure, where the rectangle indicates the window.

Viewing & Clipping

Note that the outcodes for endpoints must be recalculated on each iteration after the clipping occurs. This process is continued until the line is accepted.

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. You May Also Like: This is one of the oldest and most popular line clipping algorithm. The Cohen-Sutherland algorithm uses a divide-and-conquer strategy.