---
title: "Liang-Barsky: P1(-5,3), P2(15,9)"
subject: "Computer Graphics"
chapter: 3
key: "semester_5/computer_graphics:liang-barsky-0-0-10-10"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/liang-barsky-0-0-10-10
site: BCT Engineering
---

# Liang-Barsky: P1(-5,3), P2(15,9)

Computer Graphics · Chapter 3: Two –Dimensional Transformations

- Asked in: 2074 Asoj, 8 marks
- Video: [Liang Barsky Line Clipping Algorithm Solved Problem 1](https://www.youtube.com/watch?v=AIX4GZkAvt0) — Md. Ebrahim Hossain
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/liang-barsky-0-0-10-10
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-3

## Question

Clip the line P1P2 with P1(-5,3) and P2(15,9) with clip window having diagonal coordinate (0,0) and (10,10) using Liang-Barsky line clipping method.

## Short answer

For line (-5,3)-(15,9) with window (0,0)-(10,10), Liang-Barsky yields u1=0.25, u2=0.75. Clipped endpoints are (0,4.5) and (10,7.5).

## Answer

**Given:** P1(−5,3), P2(15,9); window xmin = 0, ymin = 0, xmax = 10, ymax = 10.

Parametric line: x = x1 + u·Δx, y = y1 + u·Δy, 0 ≤ u ≤ 1. Here Δx = 15 − (−5) = 20, Δy = 9 − 3 = 6.

```text
p1 = −Δx = −20   q1 = x1 − xmin = −5     (left)
p2 =  Δx =  20   q2 = xmax − x1 = 15     (right)
p3 = −Δy = −6    q3 = y1 − ymin = 3      (bottom)
p4 =  Δy =  6    q4 = ymax − y1 = 7      (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 | −20 | −5 | entering, u = 0.25 |
| right | 20 | 15 | leaving, u = 0.75 |
| bottom | −6 | 3 | entering, u = −0.5 |
| top | 6 | 7 | leaving, u = 1.167 |

u1 = max(0, entering values) = 0.25, u2 = min(1, leaving values) = 0.75.

Since u1 < u2, part of the line is visible.

```text
x1' = x1 + u1·Δx = −5 + 0.25×20 = 0
y1' = y1 + u1·Δy = 3 + 0.25×6 = 4.5
x2' = x1 + u2·Δx = −5 + 0.75×20 = 10
y2' = y1 + u2·Δy = 3 + 0.75×6 = 7.5
```

**Answer: the clipped line is from (0, 4.5) to (10, 7.5).**

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. For P1(-5,3), P2(15,9) the left edge gives p1 and q1 of?
   A. 20 and 5
   B. -20 and -5
   C. -20 and 5
   D. 20 and -5
   Answer: B. p1 = -Δx = -20 and q1 = x1 - xmin = -5. (Key point: p and q values)

2. What does p < 0 mean?
   A. The line leaves the window
   B. The line is parallel
   C. The line enters the window at that edge
   D. The line is rejected
   Answer: C. Negative p means entering; positive means leaving. (Key point: Entering and leaving)

3. How are u1 and u2 found?
   A. u1 = min of all, u2 = max of all
   B. u1 = 0, u2 = 1 always
   C. Both are averages
   D. u1 = max(0, entering values), u2 = min(1, leaving values)
   Answer: D. u1 is the largest entering value and u2 is the smallest leaving value. (Key point: u1 and u2)

4. What is the clipped line?
   A. (0, 4.5) to (10, 7.5)
   B. (-5, 3) to (15, 9)
   C. (0, 3) to (10, 9)
   D. (0.25, 4.5) to (0.75, 7.5)
   Answer: A. u1 = 0.25 and u2 = 0.75 give those end points. (Key point: Result)

## Related in Computer Graphics

- [Liang-Barsky: (5,120)-(80,7)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aliang-barsky-5-120-80-7) — Computer Graphics, chapter 3
- [Liang-Barsky: (6,100)-(60,5)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aliang-barsky-6-100-60-5) — Computer Graphics, chapter 3
- [Liang-Barsky: (-2,2)-(45,40)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aliang-barsky-neg2-2-45-40) — Computer Graphics, chapter 3
- [Cohen-Sutherland: window (10,10)-(40,40)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Acohen-sutherland-window-10-40) — Computer Graphics, chapter 3
- [Cohen-Sutherland: two lines vs window A-D](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Acohen-sutherland-two-lines-window-a) — Computer Graphics, chapter 3
- [Point clipping and Cohen-Sutherland (5,130)-(50,5)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Acohen-sutherland-point-clip-5-130) — Computer Graphics, chapter 3
