---
title: "Bresenham decision parameter, negative slope"
subject: "Computer Graphics"
chapter: 2
key: "semester_5/computer_graphics:bresenham-negative-slope-derive"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/bresenham-negative-slope-derive
site: BCT Engineering
---

# Bresenham decision parameter, negative slope

Computer Graphics · Chapter 2: Scan-Conversion

- Asked in: 2072 Kartik, 8 marks; 2066 Magh (old course) (asked 2 times)
- Video: [Bresenham's Line Drawing Algorithm (negative slope) Derivation |Computer Graphics](https://www.youtube.com/watch?v=vRQctZZGn1s) — Abhishek Sharma
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/bresenham-negative-slope-derive
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-2

## Question

Derive the Bresenham's decision parameter to draw a line moving from left to right and having negative slope (|m| < 1, in the first quadrant).

## Short answer

For a line with negative slope |m|<1, x increments by 1. Decision parameter p_k = 2Δx·y_k + 2|Δy|·x_k + c, with p_0 = 2|Δy| − Δx. If p_k < 0, y unchanged, p_(k+1) = p_k + 2|Δy|; else y decrements, p_(k+1) = p_k + 2|Δy| − 2Δx.

## Answer

**Case:** line from (x0, y0) to (x1, y1), x0 < x1, slope m = Δy/Δx with −1 < m < 0, so x increases by 1 each step and y either stays or decreases by 1.

Let Δx = x1 − x0 > 0 and |Δy| = y0 − y1 > 0. The line equation is y = m·x + b.

#### Pixel choice
Having plotted (x_k, y_k), the next column is x_k+1. The two candidate pixels are y_k and y_k − 1. The true y at x_k+1 is

```text
y = m(x_k + 1) + b
d1 = y_k − y            (distance to upper pixel y_k)
d2 = y − (y_k − 1)      (distance to lower pixel y_k − 1)
d1 − d2 = 2y_k − 2y − 1
        = 2y_k − 2m(x_k + 1) − 2b − 1
```

#### Decision parameter
Multiply by Δx (positive, so the sign is unchanged) and use m = −|Δy|/Δx:

```text
p_k = Δx (d1 − d2)
    = 2Δx·y_k + 2|Δy|(x_k + 1) − 2b·Δx − Δx
    = 2Δx·y_k + 2|Δy|·x_k + c      where c = 2|Δy| − 2bΔx − Δx
```

- If p_k < 0 then d1 < d2, the upper pixel is nearer: next point (x_k+1, y_k).
- If p_k ≥ 0 then d1 ≥ d2, the lower pixel is nearer: next point (x_k+1, y_k − 1).

#### Recursive form
```text
p_k+1 − p_k = 2|Δy|(x_k+1 − x_k) + 2Δx(y_k+1 − y_k) = 2|Δy| + 2Δx(y_k+1 − y_k)
```

- If y_k+1 = y_k:      p_k+1 = p_k + 2|Δy|
- If y_k+1 = y_k − 1:  p_k+1 = p_k + 2|Δy| − 2Δx

#### Initial value
At (x0, y0), y0 = m·x0 + b, so 2Δx(y0 − b) = 2Δx·m·x0 = −2|Δy|·x0. Substituting in p_0:

```text
p_0 = 2|Δy| − Δx
```

#### Algorithm
```text
1. Plot (x0, y0). p = 2|Δy| − Δx.
2. For x = x0 to x1 − 1:
      if p < 0:  plot (x+1, y);        p = p + 2|Δy|
      else:      y = y − 1; plot (x+1, y);  p = p + 2|Δy| − 2Δx
```

## Check yourself

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

1. For -1<m<0 candidates are
   A. y_k and y_k + 1
   B. y_k + 1 and y_k + 2
   C. y_k and y_k - 1
   D. x_k and x_k - 1
   Answer: C. y decreases. (Key point: Candidates)

2. p0 =
   A. 2dx - |dy|
   B. |dy| - 2dx
   C. dx + |dy|
   D. 2|dy| - dx
   Answer: D. From derivation. (Key point: Initial)

3. If p >= 0, next point is
   A. (x_k + 1, y_k - 1)
   B. (x_k + 1, y_k)
   C. (x_k + 1, y_k + 1)
   D. (x_k, y_k - 1)
   Answer: A. Lower pixel closer. (Key point: p>=0)

4. If y stays, p_next =
   A. p + 2|dy| - 2dx
   B. p + 2|dy|
   C. p - 2|dy|
   D. p + 2dx
   Answer: B. Recursive form. (Key point: Update)

## Related in Computer Graphics

- [Bresenham decision parameter, |m| > 1](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Abresenham-negative-slope-m-gt-1) — Computer Graphics, chapter 2
- [Midpoint circle algorithm and decision parameter](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Amidpoint-circle-derive) — Computer Graphics, chapter 2, asked 8×
- [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×
- [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×
- [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×
- [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×

## Related in other subjects

- [Double integral xy over ellipse in first quadrant](https://www.bctengineer.com/question.md?key=semester_2%2Fmathematics%3Adouble-integral-xy-over-ellipse) — Mathematics, chapter 2, asked 3×
- [Fleming's right and left hand rules](https://www.bctengineer.com/question.md?key=semester_4%2Felectrical_machine%3Afleming-hand-rules) — Electrical Machine, chapter 1
- [Left and right focal point ratios](https://www.bctengineer.com/question.md?key=semester_5%2Ftheory_of_structures_ii%3Afocal-point-ratios-left-right) — Theory of Structures II, chapter 4
- [First product of inertia of right-angled triangle](https://www.bctengineer.com/question.md?key=semester_3%2Fstrength_of_materials%3Aproduct-of-inertia-right-triangle) — Strength of Materials, chapter 2
