PadhaikoAll subjects

Past exam question: 2081 Chaitra (Regular), Q2(c)

Computer Graphics and Visualization · 4 marks

Open in the Padhaiko app

Topic: Point, Line (Cohen–Sutherland, Liang–Barsky), Polygon & Text Clipping

Question

Use the Cohen-Sutherland line clipping algorithm to clip two lines P1(40,50) - P2(75,45) and P3(70,20) - P4(100,10) against a window A (50,10), B (80,10), C (80,40) and D (50,40).

Solution

Clipping Window Boundaries and 4-Bit Region Code (Outcode): The rectangular clipping window has corners , , , and :

In the Cohen-Sutherland algorithm, 2D space is partitioned into 9 regions relative to the window. Each endpoint is assigned a 4-bit region code [Top, Bottom, Right, Left] (TBRL):

Clipping Analysis for Line 1: :

  1. Compute outcodes for both endpoints:
    • For :
    • For :
  2. Test for trivial acceptance / rejection:
    • Bitwise OR: (not trivially accepted).
    • Bitwise AND: .
    • Since the bitwise AND is non-zero, both endpoints share a common outside half-plane (Bit 1 is , meaning both endpoints lie entirely above the top boundary ).
    • Therefore, Line 1 is completely outside / trivially rejected and completely discarded.

Clipping Analysis for Line 2: :

  1. Compute outcodes:
    • For :
      • and (inside window).
    • For :
      • .
      • .
      • .
  2. Test for trivial acceptance / rejection:
    • Bitwise OR: (not trivially accepted).
    • Bitwise AND: (not trivially rejected; line partially visible, clipping required).

Intersection Calculation for Line 2: Endpoint is outside the right boundary (). The slope of line is:

Find the intersection with the right boundary line :

Checking the range of :

The intersection point lies strictly on the right edge of the window. Its outcode is . Now both endpoints and have outcode , so the clipped segment is accepted.

Answer:
  1. Line 1 (): , . Bitwise AND is Trivially Rejected (completely outside the top boundary).
  2. Line 2 (): , . Partially visible; clipped against the right boundary at:

The accepted clipped segment is from to .

All past exam questions for Computer Graphics and Visualization