Professional Documents
Culture Documents
Lecture - Line Scan Conversion
Lecture - Line Scan Conversion
Z
Y
m=∞
m = -4 m=4
m = -2 m=2
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
July 20, 2023 Computer Graphics discontinuity !! 24
DDA Algorithm - Generic solution
– What is m<0 ?
– We must see the sign of x and y
Various x>0 x>0 x<0 x<0
Cases y>0 y<0 y>0 y<0
– e.g. if m=.333 …
Specified
Line Path
0 m 1
Specified
Line Path
Q2
yk 1 d2
yk 2 y Q
yk 1 Q2 d1
Q
y mx b yk Q1
yk P Q1 P
xk 1
xk xk 1 xk 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)
July 20, 2023 Computer Graphics 44
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
July 20, 2023 Computer Graphics 45
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)
July 20, 2023 Computer Graphics 46