**COM1370 Computer Graphics --
Quiz 1 -- Thursday, June 28**^{th}

#### 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.

- Assume that you are given a line with
initial coordinates
`x`_{0} = 1, y_{0} = 2
and end coordinates `x`_{end} = 5
and `y`_{end} = 5.

For this case then,
`delX = 4` and `delY = 3`.

- First, plot
`x`_{0} and `y`_{0}

- Compute the initial decision parameter
`p`_{0} = 2 * delY - delX

- At each
`x`_{k} along the line, starting at k = 0,
perform the following test:

If `p`_{k} < 0, the next point to plot is
`(x`_{k} + 1, y_{k}) and

`p`_{k+1} = p_{k} + 2 * delY

Otherwise, the next point to plot is `(x`_{k} + 1, y_{k} + 1) and

`p`_{k+1} = p_{k} + 2 * delY - 2 * delX

- 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 p_{k} (x_{k+1}, y_{k+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.)