Let R be the rectangular window against which the lines are to be clipped…
2016
Let R be the rectangular window against which the lines are to be clipped using 2D Sutherland-Cohen line clipping algorithm. The rectangular window has lower left-hand corner at (– 5, 1) and upper right-hand corner at (3, 7). Consider the following three lines for clipping with the given end point co-ordinates :
Line AB : A (– 6, 2) and B (–1, 8)
Line CD : C (– 1, 5) and D (4, 8)
Line EF : E (–2, 3) and F (1, 2)
Which of the following line(s) is/are candidate for clipping ?
- A.
AB
- B.
CD
- C.
EF
- D.
AB and CD
Attempted by 53 students.
Show answer & explanation
Correct answer: D
Answer: Lines AB and CD are candidates for clipping.
Line AB: A(–6,2) is left of the window and B(–1,8) is above the window. Their region codes share no common set bit (bitwise AND = 0), so the line is neither trivially accepted nor trivially rejected and must be processed by the Cohen–Sutherland clipping algorithm.
Line CD: C(–1,5) lies inside the window while D(4,8) lies outside to the right and above. With one endpoint inside and the other outside (bitwise AND = 0), this line must be clipped.
Line EF: E(–2,3) and F(1,2) are both inside the window. This line is trivially accepted and does not require clipping.
Summary: Apply the Cohen–Sutherland algorithm to lines AB and CD; EF is already inside.