Graphics / Playgrounds / DDA vs Bresenham

DDA vs Bresenham draft

DDA vs Bresenham opens on DDA so you can trace one segment, then switch methods while keeping the same endpoints. Use Step, Back, Run and Reset to compare the floating-point state carried by DDA with the error state used by Bresenham, or switch to the floating-endpoint form to inspect its initialisation.

first octant: x0 < x1, 0 <= m <= 1
0123456789101101234567
m
(y1 - y0)/(x1 - x0) = 0.444
yi
y0 = 1
  1. x = 1: yi = y0 = 1; y = round(yi) = 1
  2. x = 2: yi = yi + m = 1.444; y = round(yi) = 1
  3. x = 3: yi = yi + m = 1.889; y = round(yi) = 2
  4. x = 4: yi = yi + m = 2.333; y = round(yi) = 2
  5. x = 5: yi = yi + m = 2.778; y = round(yi) = 3
  6. x = 6: yi = yi + m = 3.222; y = round(yi) = 3
  7. x = 7: yi = yi + m = 3.667; y = round(yi) = 4
  8. x = 8: yi = yi + m = 4.111; y = round(yi) = 4
  9. x = 9: yi = yi + m = 4.556; y = round(yi) = 5
  10. x = 10: yi = yi + m = 5; y = round(yi) = 5
0 / 10

Reference