|
Using the error term.
Here we see how the cumulative error influences pixel choice. The
figure depicts a line, and the pixels that best approximate that line. In the bottom figure is a graph of the cumulative error.
In this example, the line's slope is 1/3. When we move one pixel to
the right, the error increases by 1/3 (or the amount of the slope.) As long as the error is less than 1/2, the lower pixel is closer to the line. When the error is greater than 1/2, we choose the upper pixel. Notice that when the pixel's y-coordinate increases by one, the pixel jumps to a position above the true line, and the error decreases by one.
If we use this approach, we can use integers to store the x and y
coordinates of the pixel location, and we ask the question
is the error > 1/2 ?
to decide whether to adjust the y-coordinate of the next pixel.
|