- Asked 4/25
- 2079 Baisakh · 5 marks
Bresenham: line (10,20) to (15,2)
Short answer
Use Bresenham with |m|>1 negative. p0 = 2*5 – 18 = –8. y decrements each step; when p<0, x stays, p+=10; when p≥0, x+=1, p–=26. Resulting pixels: (10,20), (10,19), (11,18), (11,17), (11,16), (11,15), (12,14), (12,13), (12,12), (13,11), (13,10), (13,9), (13,8), (14,7), (14,6), (14,5), (14,4), (15,3), (15,2).
Digitize a line with end points (10,20) and (15,2) using Bresenham's algorithm.
Given: (10,20) to (15,2). Δx = 5, |Δy| = 18, the slope is negative with |m| = 3.6 > 1. So y is decremented by 1 at each step and the decision parameter decides whether x stays or increases.
p0 = 2Δx − |Δy| = 10 − 18 = −8
If p < 0: x same, p = p + 2Δx = p + 10
If p ≥ 0: x + 1, p = p + 2Δx − 2|Δy| = p − 26
| k | p_k | (x_k, y_k) |
|---|---|---|
| 0 | -8 | (10,20) |
| 1 | 2 | (10,19) |
| 2 | -24 | (11,18) |
| 3 | -14 | (11,17) |
| 4 | -4 | (11,16) |
| 5 | 6 | (11,15) |
| 6 | -20 | (12,14) |
| 7 | -10 | (12,13) |
| 8 | 0 | (12,12) |
| 9 | -26 | (13,11) |
| 10 | -16 | (13,10) |
| 11 | -6 | (13,9) |
| 12 | 4 | (13,8) |
| 13 | -22 | (14,7) |
| 14 | -12 | (14,6) |
| 15 | -2 | (14,5) |
| 16 | 8 | (14,4) |
| 17 | -18 | (15,3) |
| 18 | -8 | (15,2) |
Pixels:
(10,20) (10,19) (11,18) (11,17) (11,16) (11,15) (12,14) (12,13)
(12,12) (13,11) (13,10) (13,9) (13,8) (14,7) (14,6) (14,5)
(14,4) (15,3) (15,2)
Answer: 19 pixels from (10,20) to (15,2) as listed.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Bresenham: line (20,10) to (30,18) · Computer Graphics, chapter 2 · asked 4×
- Bresenham: line (25,20) to (15,10) · Computer Graphics, chapter 2
- Bresenham: endpoints (10,18),(15,8) · Computer Graphics, chapter 2
- DDA versus Bresenham line algorithm · Computer Graphics, chapter 2 · asked 6×
- Write Bresenham's line algorithm · Computer Graphics, chapter 2 · asked 3×
- Bezier points at u=0.25,0.5,0.75: (10,15)... · Computer Graphics, chapter 5 · asked 4×
- Bresenham's algorithm for all slopes · Computer Graphics, chapter 2
- Laplace: 2x2 grid 10/15/20 · Numerical Method, chapter 7 · asked 6×
- Fault at far end of 33 kV line · Power System Analysis II, chapter 3
- Fault at load end of overhead line · Power System Analysis II, chapter 3
- Reactance diagram: 20 MVA generator, 15 kV/25 MVA base · Power System Analysis I, chapter 3