- 2081 Chaitra (new course) · 4 marks
Cohen-Sutherland: two lines vs window A-D
Short answer
Line P1(40,50)-P2(75,45) is above the window and rejected. Line P3(70,20)-P4(100,10) is partly outside; after clipping it becomes (70,20)-(80,16.67).
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).
Window: A(50,10), B(80,10), C(80,40), D(50,40), so xmin = 50, ymin = 10, xmax = 80, ymax = 40.
Region code (T B R L): bit 1 = 1 if x < xmin, bit 2 = 1 if x > xmax, bit 3 = 1 if y < ymin, bit 4 = 1 if y > ymax. Slope m = (y2 − y1)/(x2 − x1); intersections: y = y1 + m(x − x1) with a vertical edge, x = x1 + (y − y1)/m with a horizontal edge.
Line 1: P1(40, 50), P2(75, 45)
Region codes (T B R L): P1 = 1001, P2 = 1000.
P1=(40,50) code 1001; P2=(75,45) code 1000
Logical AND of codes = 1000 (not 0000): reject
Both end points are above the window, so the line is rejected (completely outside the window).
Line 2: P3(70, 20), P4(100, 10), m = −10/30 = −1/3
Region codes (T B R L): P3 = 0000, P4 = 0010.
P3=(70,20) code 0000; P4=(100,10) code 0010
Clip P4 against x = xmax = 80: new point (80,16.67)
P3=(70,20) code 0000; P4=(80,16.67) code 0000
Both codes 0000: accept
Clipped line: (70, 20) to (80, 16.67).
Answer: the line P1P2 is rejected, and the line P3P4 is clipped to (70, 20) - (80, 16.67).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Cohen-Sutherland: window (10,10)-(40,40) · Computer Graphics, chapter 3
- Point clipping and Cohen-Sutherland (5,130)-(50,5) · Computer Graphics, chapter 3
- Cohen-Sutherland line clipping · Computer Graphics, chapter 3 · asked 2×
- Cohen-Sutherland: (0,120)-(130,5) · Computer Graphics, chapter 3
- Liang-Barsky: P1(-5,3), P2(15,9) · Computer Graphics, chapter 3
- AVL tree for 10 20 30 50 45 40 8 5 3 · Data Structure and Algorithm, chapter 6
- Conductor selection, 100 MW 70 km 132 kV · Transmission and Distribution System Design, chapter 4