|
Brute force scan conversion.
We can use the equation of the line directly to perform a
scan-conversion. Starting at the pixel for the left-hand endpoint of the line, xl, we step along the pixels horizontally, until we reach the right-hand end of the line, xr. For each pixel we use the equation 'y = mx + b' to compute the corresponding y value. We then round this value to the nearest integer to select the nearest pixel. We might write this in C as follows:
x = xl;
while (x <= xr){
ytrue = m*x + b;
y = Round (ytrue);
PlotPixel (x, y);
/* Set the pixel at (x,y) on */
x = x + 1;
}
The slide shows that because the line equation is evaluated for
every step in x, we need to perform a floating-point multiplication
each time. This method therefore requires an enormous number of
floating-point multiplications, and is therefore expensive.
|