Sutherland–Cohen Line Clipping Algorithm

The Sutherland–Cohen algorithm is a line clipping technique that uses region codes to efficiently determine the visible portion of a line within a rectangular clipping window.

1. Line Clipping

Line clipping determines which portion of a line segment lies inside the clipping window and removes the rest.

2. Idea of Cohen–Sutherland Algorithm

The algorithm divides the 2D space into nine regions around the clipping window and assigns a unique 4-bit region code to each endpoint of a line.

3. Region Codes (Outcodes)

Bit 1: Top
Bit 2: Bottom
Bit 3: Right
Bit 4: Left

4. Trivial Acceptance

If both endpoints of a line have region code 0000, the line lies completely inside the window and is accepted.

5. Trivial Rejection

If the logical AND of region codes of both endpoints is non-zero, the line lies completely outside and is rejected.

6. Partial Clipping

If neither trivial acceptance nor rejection applies, the line partially intersects the window and clipping is required.

7. Steps of Cohen–Sutherland Algorithm

8. Example

For a line intersecting the right boundary of the window:

9. Advantages

10. Disadvantages

11. Applications

Practice Questions

  1. What is Cohen–Sutherland algorithm?
  2. What are region codes?
  3. Explain trivial acceptance and rejection.
  4. How is partial clipping performed?
  5. List advantages of the algorithm.

Practice Task

Explain with diagrams: ✔ Region codes ✔ Line clipping cases ✔ Step-by-step clipping example