COM1370 Computer Graphics -- Quiz 1 -- Thursday, June 28th

Summer 2001 -- Professor Futrelle
College of Computer Science, Northeastern U., Boston, MA


PRINT your name clearly ________________________________________________ Your ID no. ________________


Question 1.

The following is a description of the Bresenham line-drawing algorithm. You are to use it to fill in a table of values, as described below.

  1. Assume that you are given a line with initial coordinates x0 = 1, y0 = 2 and end coordinates xend = 5 and yend = 5.
    For this case then, delX = 4 and delY = 3.


  2. First, plot x0 and y0


  3. Compute the initial decision parameter p0 = 2 * delY - delX


  4. At each xk along the line, starting at k = 0, perform the following test:
    If pk < 0, the next point to plot is (xk + 1, yk) and
    pk+1 = pk + 2 * delY
    Otherwise, the next point to plot is (xk + 1, yk + 1) and
    pk+1 = pk + 2 * delY - 2 * delX


  5. Repeat step 4 delX times.


Fill your values in the following table. (If you change your mind, no need to erase, you can construct another table.)

________________________________________________

k      pk     (xk+1, yk+1)
________________________________________________











________________________________________________

When you're done, draw a grid of pixels from x and y = 0 to x and y = 5 and shade in the pixels that your table shows are to be plotted. Does your line appear to be computed properly? (If not, try to correct your table.)














Question 2.

Describe how to compute the pixels to plot using the DDA algorithm applied to the line in Question 1. (You'll find it convenient to do your computations using values of the form 3 3/4, etc.)