- Asked 4/25
- 2074 Asoj · 10 marks
- 2078 Bhadra · 7 marks
- 2070 Asar · 7 marks
Bresenham: line (20,10) to (30,18)
Short answer
dx=10, dy=8, p0=6. If p<0 y unchanged and p+=16; else y incremented and p-=4. Pixels: (20,10), (21,11), (22,12), (23,12), (24,13), (25,14), (26,15), (27,16), (28,16), (29,17), (30,18).
Digitize the line with end points A(20,10) and B(30,18) using Bresenham's algorithm.
Given: A(20,10), B(30,18). Slope is 0 < m = 8/10 < 1, so x is incremented by 1 at each step.
dx = 30 − 20 = 10, dy = 18 − 10 = 8
2dy = 16, 2dy − 2dx = 16 − 20 = −4
p0 = 2dy − dx = 16 − 10 = 6
Rule: if p_k < 0: next point (x+1, y), p_k+1 = p_k + 2dy = p_k + 16. If p_k ≥ 0: next point (x+1, y+1), p_k+1 = p_k + 2dy − 2dx = p_k − 4.
| k | p_k | (x_k, y_k) | Next point | p_k+1 |
|---|---|---|---|---|
| 0 | 6 | (20,10) | (21,11) | 2 |
| 1 | 2 | (21,11) | (22,12) | -2 |
| 2 | -2 | (22,12) | (23,12) | 14 |
| 3 | 14 | (23,12) | (24,13) | 10 |
| 4 | 10 | (24,13) | (25,14) | 6 |
| 5 | 6 | (25,14) | (26,15) | 2 |
| 6 | 2 | (26,15) | (27,16) | -2 |
| 7 | -2 | (27,16) | (28,16) | 14 |
| 8 | 14 | (28,16) | (29,17) | 10 |
| 9 | 10 | (29,17) | (30,18) | 6 |
| 10 | 6 | (30,18) | - | - |
Pixels plotted:
(20,10) (21,11) (22,12) (23,12) (24,13) (25,14)
(26,15) (27,16) (28,16) (29,17) (30,18)
Answer: the 11 pixels above, from (20,10) to (30,18).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Bresenham: line (10,20) to (15,2) · 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×
- Midpoint circle: r=10, centre (20,30) · Computer Graphics, chapter 2
- 3D rotation about axis (1,2,3)-(10,20,30) · Computer Graphics, chapter 4
- AVL tree for 10 20 30 50 45 40 8 5 3 · Data Structure and Algorithm, chapter 6
- AVL tree for 10, 20, 30, 35, 50, ... · Data Structure and Algorithm, chapter 6
- Series 1×10+3×20+6×30+… · Computer Programming, chapter 5
- Audible noise of 765 kV line (18 kV/cm outer) · High Voltage Engineering, chapter 5 · asked 4×