Cohen-Sutherland Line Clipping
Segment clipping based on 4-bit region outcodes.
Outcode Regions
Divide the coordinate space into 9 regions using 4 bits: Top, Bottom, Right, Left (TBRL).
- Inside window:
0000 - Left of window:
0001 - Right of window:
0010 - Bottom of window:
0100 - Top of window:
1000
Trivial Tests
- Trivial Accept: Both endpoint codes are
0000(line is completely inside). - Trivial Reject: Logical AND of both codes is NOT zero (both points share an outside region, so line is entirely outside).
Ready to Visualize Line Clipping?
Launch our interactive visualizer to step through calculations in real-time.
Launch Cohen-Sutherland Visualizer →