Q5. Show the values of the decision function and the pixels selected by the Bresenham line algorithm for the line from (1,2) to (8,12).
Bresenham's Line Algorithm for |m| < 1:
1. Input the two endpoints and store the left endpoint in (xo, yo).
2. Load (xo, yo) into the frame buffer; i.e. plot the first point.
3. Obtain the starting value for the decision function do = 2dy - dx.
4. At each xt along the line, starting at k = 0, perform the following test:
- If di < 0, the next point to plot is (x + 1, y) and di+1 = di + 2dy.
- Otherwise, the next point to plot is (xt + 1, yt + 1) and di+1 = di + 2(dy - dx).
5. Repeat step 4 deltax times.
T
y
2
0
(8,12)
2
3
5
(1,2)
6
d = 2(dy) - (dx)
Initial value: 2(dy) - (dx)
Case 1: di + 1 = 2dy
Case 2: di + 1 = 2(dy - dx)