The Best-Fit DDA Algorithm

The Best-Fit DDA is an algorithm for converting a segment into a nice-looking sequence of pixels. The conversion of a segment from to with involves a sequence of steps. At each step the segment is approximated by the concatenation of copies of a path with copies of a path . Initially, , , (a single horizontal increment), and (a diagonal increment). Update: if then , , else , The algorithm terminates when .


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


This is a fast algorithm used in raster-scan systems. It is based on the subtractive version of Euclid's algorithm for the computation of the GCD of two positive integers and . The classical algorithm of Bresenham for drawing line segments is strictly related to the optimal placement of leap years in a cycle of years, and both are related to the Best-Fit DDA via Euclid's algorithm for the GCD of and and the continued fraction expansion of .
The Best-Fit DDA is described in Sect. 2.5 of D. Salomon, Computer Graphics and Geometric Modeling, New York: Springer-Verlag, 1999.
The Best-Fit DDA is due to C. M. A. Castle and M. L. V. Pitteway, "An Application of Euclid's Algorithm to Drawing Straight Lines," in Fundamental Algorithms for Computer Graphics, (R. A. Earnshaw, ed.), New York: Springer-Verlag, 1985 pp. 135-139.
The striking connections among Bresenham's algorithm, leap years, and Euclid's algorithm are discussed in M. A. Harris and E. M. Reingold, "Line Drawing, Leap Years, and Euclid," ACM Computing Surveys, 36(1), 2004 pp. 68–80.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Powered by Wolfram Mathematica © 2014 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+