The midpoint line algorithm is due to Bresenham [Bre65] and was modified by Pitteway [Pit67] and Van Aken [VA84]. It works as follows: Let the slope of the line be . Suppose one approximate point is already determined. We have only two choices for the next point, namely and and we should choose the one which is closer to . To determine the appropriate choice we proceed as follows:
In oder to check this condition we consider the implicit equation
Lines with other slopes can be obtained by mirroring.
Some issues concerning this algorithm have to be taken into account, cf. [FvDFH90, 3.2.3]:
E.g., the following line from to :
Do not clip (see (2.5) below) and then scan-convert if line hits the left boundary of the clipping rectangle.
In case of a horizontal boundary we may miss some points at the beginning. In oder to avoid this we should start at the intersection point with the line below the horizontal lower boundary
The number of pixel per length depends on the slope. It will be 1 for horizontal lines and for slope 1.
So one could modify the intensity of pixels drawn. Another (and even better method) is anti-aliasing as discussed below.
Andreas Kriegl 2003-07-23