Line Scan Conversion in Computer Graphics
Line Scan Conversion in Computer Graphics
Z
Y
m = -1 m=1
m = -1 / 2 m = 1 /2
m = -1 / 3 m = 1 /3
– Take unit step increment along direction having more rate of change, and
compute the coordinates for the other position to maximize the number of
points to be computed along the path of line and avoid discontinuities
xi 1 : xi 1
yi 1 : yi m 0 m 1
or Why?
yi 1 : yi 1
1
xi 1 : xi 1 m
m
March 2, 2018 Computer Graphics discontinuity !! 26
DDA Algorithm - Generic solution
– What is m<0 ?
– We must see the sign of Dx and Dy
Various Dx>0 Dx>0 Dx<0 Dx<0
Cases Dy>0 Dy<0 Dy>0 Dy<0
– e.g. if m=.333 …
Specified
Line Path
0 m 1
Specified
Line Path
yk 1 Q2
yk 2 d2
y Q
yk 1 Q2 d1
yk P
Q
Q1
y mx b yk P
Q1
xk 1
xk xk 1xk 2 0 m 1, xk xl , k l
k pk (xk+1, yk+1)
k pk (xk+1, yk+1)
0 3
1 1 (14, 12)
2 -1 (15, 12)
3 7 (16, 13)
4 5 (17, 14)
March 2, 2018 Computer Graphics 46
Bresenham’s Line Algorithm
5. Exercise: Trace for (20,10) to (30,18)
k pk (xk+1,yk+1)
18
17
16
15
14
13
12
11
10
20 21 22 23 24 25 26 27 28 29 30
March 2, 2018 Computer Graphics 47
Bresenham’s Line Algorithm
Answer k pk (xk+1,yk+1)
18
0 6 (21,11)
17 1 2 (22,12)
16 2 -2 (23,12)
15 3 14 (24,13)
14 4 10 (25,14)
13 5 6 (26,15)
12 6 2 (27,16)
11 7 -2 (28,16)
10 8 14 (29,17)
20 21 22 23 24 25 26 27 28 29 30 9 10 (30,18)