---
title: "Bresenham: line (25,20) to (15,10)"
subject: "Computer Graphics"
chapter: 2
key: "semester_5/computer_graphics:digitize-line-25-20-15-10"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/digitize-line-25-20-15-10
site: BCT Engineering
---

# Bresenham: line (25,20) to (15,10)

Computer Graphics · Chapter 2: Scan-Conversion

- Asked in: 2075 Chaitra, 8 marks
- Video: [Bresenham line algorithm with example in computer graphics | Lec-14](https://www.youtube.com/watch?v=nLJzeIXBHS8) — Er Sahil ka Gyan
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/digitize-line-25-20-15-10
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-2

## Question

Explain the Bresenham line drawing algorithm and use this algorithm to draw a line with end points (25,20) and (15,10).

## Short answer

Start at left point (15,10). dx=10, dy=10, p0=2*10−10=10. Since p remains ≥0, both x and y increment each step. Pixels: (15,10), (16,11), (17,12), (18,13), (19,14), (20,15), (21,16), (22,17), (23,18), (24,19), (25,20).

## Answer

#### Bresenham's line algorithm
It draws a line using only integer arithmetic. For 0 < m < 1 with the left end point as start:

```text
1. dx = x2 − x1, dy = y2 − y1; plot (x1, y1).
2. p0 = 2dy − dx.
3. For each step, x = x + 1:
     if p < 0: y same;  p = p + 2dy
     else:     y = y + 1; p = p + 2dy − 2dx
     plot (x, y)
```
For m = 1 the same steps are used; for steeper lines the roles of x and y are interchanged.

#### Numerical
The end points are (25,20) and (15,10). The line is drawn from left to right, so start at the left point (15,10) and end at (25,20) (the pixel set is the same).

```text
dx = 25 − 15 = 10,  dy = 20 − 10 = 10,  slope m = 1
2dy = 20,  2dy − 2dx = 0
p0 = 2dy − dx = 20 − 10 = 10
```

| k | p_k | (x_k, y_k) | Next |
|---|---|---|---|
| 0 | 10 | (15,10) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 1 | 10 | (16,11) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 2 | 10 | (17,12) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 3 | 10 | (18,13) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 4 | 10 | (19,14) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 5 | 10 | (20,15) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 6 | 10 | (21,16) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 7 | 10 | (22,17) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 8 | 10 | (23,18) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 9 | 10 | (24,19) | p ≥ 0: (x+1, y+1), p = p + 0 |
| 10 | 10 | (25,20) | - |

Since p stays 10 (positive), y is increased every time.

**Answer: (15,10), (16,11), (17,12), (18,13), (19,14), (20,15), (21,16), (22,17), (23,18), (24,19), (25,20).**

## Check yourself

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

1. For end points (25,20) and (15,10), the slope is:
   A. 1, since dx = dy = 10
   B. 0.5
   C. 2
   D. −1
   Answer: A. dy/dx = 10/10 = 1, so the 0 < m <= 1 steps apply. (Key point: Slope)

2. p0 = 2dy − dx equals:
   A. 20
   B. 0
   C. 10
   D. 30
   Answer: C. 2(10) − 10 = 10. (Key point: Initial parameter)

3. Why does y increase at every step in this example?
   A. p is always negative so y moves
   B. 2dy − 2dx = 0, so p stays at 10 (≥ 0) and the diagonal pixel is always chosen
   C. Because the line is drawn right to left
   D. Because dx is greater than dy
   Answer: B. With p ≥ 0 every time, y = y+1 and p changes by 2dy − 2dx = 0. (Key point: Behaviour of p)

## Related in Computer Graphics

- [Bresenham: line (10,20) to (15,2)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adigitize-line-10-20-15-2) — Computer Graphics, chapter 2, asked 4×
- [Bresenham: line (20,10) to (30,18)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adigitize-line-20-10-30-18) — Computer Graphics, chapter 2, asked 4×
- [Bezier points at u=0.25,0.5,0.75: (10,15)...](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Abezier-points-control-10-15) — Computer Graphics, chapter 5, asked 4×
- [DDA versus Bresenham line algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adda-vs-bresenham-line) — Computer Graphics, chapter 2, asked 6×
- [Write Bresenham's line algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Abresenham-line-algorithm) — Computer Graphics, chapter 2, asked 3×
- [Bresenham: endpoints (10,18),(15,8)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adigitize-point-10-18-15-8) — Computer Graphics, chapter 2

## Related in other subjects

- [Reactance diagram: 20 MVA generator, 15 kV/25 MVA base](https://www.bctengineer.com/question.md?key=semester_4%2Fpower_system_analysis_i%3Areactance-diagram-20mva-15kv-25mva) — Power System Analysis I, chapter 3
- [Laplace: 2x2 grid 10/15/20](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Alaplace-2x2-10-15-20-25) — Numerical Method, chapter 7, asked 6×
- [Fault at far end of 33 kV line](https://www.bctengineer.com/question.md?key=semester_5%2Fpower_system_analysis_ii%3Afault-far-end-33kv-line) — Power System Analysis II, chapter 3
- [Fault at load end of overhead line](https://www.bctengineer.com/question.md?key=semester_5%2Fpower_system_analysis_ii%3Afault-load-end-33kv-line) — Power System Analysis II, chapter 3
