- 2072 Kartik · 8 marks
Liang-Barsky: (5,120)-(80,7)
Short answer
Using Liang-Barsky with window (10,10)-(100,100) on line (5,120)-(80,7), u1=0.177, u2=0.9735, giving clipped points (18.27,100) and (78.01,10).
Find the clipped region in window of diagonal vertex (10,10) and (100,100) for line P1 (5,120) and P2 (80,7) using Liang-Barsky line clipping method.
Given: P1(5,120), P2(80,7); window xmin = 10, ymin = 10, xmax = 100, ymax = 100.
Parametric line: x = x1 + u·Δx, y = y1 + u·Δy, 0 ≤ u ≤ 1. Here Δx = 80 − 5 = 75, Δy = 7 − 120 = −113.
p1 = −Δx = −75 q1 = x1 − xmin = −5 (left)
p2 = Δx = 75 q2 = xmax − x1 = 95 (right)
p3 = −Δy = 113 q3 = y1 − ymin = 110 (bottom)
p4 = Δy = −113 q4 = ymax − y1 = −20 (top)
For p < 0 the line enters the window, and u = q/p is a candidate for u1 = max(0, ...); for p > 0 it leaves, and u = q/p is a candidate for u2 = min(1, ...).
| Edge | p | q | u = q/p and remark |
|---|---|---|---|
| left | −75 | −5 | entering, u = 0.067 |
| right | 75 | 95 | leaving, u = 1.267 |
| bottom | 113 | 110 | leaving, u = 0.9735 |
| top | −113 | −20 | entering, u = 0.177 |
u1 = max(0, entering values) = 0.177, u2 = min(1, leaving values) = 0.9735.
Since u1 < u2, part of the line is visible.
x1' = x1 + u1·Δx = 5 + 0.177×75 = 18.27
y1' = y1 + u1·Δy = 120 + 0.177×(−113) = 100
x2' = x1 + u2·Δx = 5 + 0.9735×75 = 78.01
y2' = y1 + u2·Δy = 120 + 0.9735×(−113) = 10
Answer: the clipped line is from (18.27, 100) to (78.01, 10).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Liang-Barsky: P1(-5,3), P2(15,9) · Computer Graphics, chapter 3
- Liang-Barsky: (6,100)-(60,5) · Computer Graphics, chapter 3
- Liang-Barsky: (-2,2)-(45,40) · Computer Graphics, chapter 3
- Cohen-Sutherland: window (10,10)-(40,40) · Computer Graphics, chapter 3
- Point clipping and Cohen-Sutherland (5,130)-(50,5) · Computer Graphics, chapter 3