- 2075 Asoj · 8 marks
Liang-Barsky: (6,100)-(60,5)
Short answer
Line from (6,100) to (60,5); window (10,10)–(90,90). Δx=54, Δy=−95. p,q yield entering u from left (0.074) and top (0.1053), leaving from right (1.556) and bottom (0.9474). u1=max(0,0.074,0.1053)=0.1053, u2=min(1,0.9474)=0.9474. Clipped endpoints: x1'=6+0.1053×54≈11.68, y1'=100−0.1053×95=90; x2'=6+0.9474×54≈57.16, y2'=100−0.9474×95=10. Clipped line: (11.68, 90) to (57.16, 10).
Use Liang-Barsky line clipping algorithm to clip a line starting from (6,100) and ending at (60, 5) against the window having its lower left corner at (10, 10) and upper right corner at (90, 90).
Given: P1(6,100), P2(60,5); window xmin = 10, ymin = 10, xmax = 90, ymax = 90.
Parametric line: x = x1 + u·Δx, y = y1 + u·Δy, 0 ≤ u ≤ 1. Here Δx = 60 − 6 = 54, Δy = 5 − 100 = −95.
p1 = −Δx = −54 q1 = x1 − xmin = −4 (left)
p2 = Δx = 54 q2 = xmax − x1 = 84 (right)
p3 = −Δy = 95 q3 = y1 − ymin = 90 (bottom)
p4 = Δy = −95 q4 = ymax − y1 = −10 (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 | −54 | −4 | entering, u = 0.074 |
| right | 54 | 84 | leaving, u = 1.556 |
| bottom | 95 | 90 | leaving, u = 0.9474 |
| top | −95 | −10 | entering, u = 0.1053 |
u1 = max(0, entering values) = 0.1053, u2 = min(1, leaving values) = 0.9474.
Since u1 < u2, part of the line is visible.
x1' = x1 + u1·Δx = 6 + 0.1053×54 = 11.68
y1' = y1 + u1·Δy = 100 + 0.1053×(−95) = 90
x2' = x1 + u2·Δx = 6 + 0.9474×54 = 57.16
y2' = y1 + u2·Δy = 100 + 0.9474×(−95) = 10
Answer: the clipped line is from (11.68, 90) to (57.16, 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: (5,120)-(80,7) · Computer Graphics, chapter 3
- Liang-Barsky: (-2,2)-(45,40) · Computer Graphics, chapter 3
- Cohen-Sutherland: two lines vs window A-D · Computer Graphics, chapter 3
- Cohen-Sutherland: window (10,10)-(40,40) · Computer Graphics, chapter 3
- Cohen-Sutherland line clipping · Computer Graphics, chapter 3 · asked 2×
- Arch 100 m rise 12 m: rolling UDL 60 m, section 10 m · Theory of Structures I, chapter 6
- Copy string converting lower to upper using pointer · Computer Programming, chapter 9 · asked 3×
- 8085 ALP: add upper and lower nibbles · Microprocessor, chapter 2
- Arch 100 m rise 15 m: rolling UDL 10 m, section 60 m · Theory of Structures I, chapter 6