Scan Conversion: Drawing a Straight Line

General Theory

The general problem of scan conversion is which pixels to turn
on. For example, assume a line with positive slope in the first
octant, i.e., 0.0 <= m <= 1.0.

and drawn from left to right: (X1, Y1) to (X2, Y2):

The problem is that as we increment xi to xi+1, do we turn on
xi+1, yi or xi+1, yi+1?

The general goal is to minimize the stair-step effect
(jaggies), have a uniform line density, and require the minimum
drawing time. Remember, we must always round or truncate to
integers since pixels are at integer positions.

The equation for a straight line: y = m * x + b, where m is
the slope (m = dy/dx) and b is the y intercept. So for a given x
interval (dx) we can compute dy = m * dx, but this is a brute
force real number computation and is very slow.

Alternative Method - Parametric Equations

For a line segment x1, y1 -> x2, y2:

x = x1 + t*dx with dx = x2 - x1 and 0.0 <= t <= 1.0

So start with t = 0 and increment to t = 1.0, e.g. t= .05,
.10,.15, etc. This is still too slow but parametric equations are
used for clipping, curve fitting, and ray tracing.

The basis of the DDA method is to take unit steps along one
coordinate and compute the corresponding values along the other
coordinate. The unit steps are always along the coordinate of
greatest change, e.g. if dx = 10 and dy = 5, then we would take
unit steps along x and compute the steps along y.

Let us assume a line of positive slope and draw from x1, y1 to
x2, y2.