1. By using Digital Differential Analyzer algorithm draw line segments from point (1,1) to (9,7).
Ans. We see that the usual equation of the line is specified by:
y = mx+c, here m = (y_{1} - y_{0}/( x_{1} - x_{0})
Specified (x_{0}, y_{0}) → (1, 1) ; (x_{1}, y_{1}) → (9, 7)
⇒ m = (7-1)/(9-1) =6/8
C = y_{1} - mx_{1} = 7 - (6/8) *9 = 1/4
Consequently, by equation of line (y = mx + c) we contain:
y = (6/8)x+(1/4)
Digital Differential Analyzer Algorithm Two case:
Case 1: m < 1
x_{i} _{+ 1} = x_{i} + 1
y_{i + 1} = y_{i} + m
Case 2: m > 1
x_{i + 1} = x_{i} + (1/m)
y_{i} _{+ 1} = y_{i} + 1
Here m < 1 so as per to Digital Differential Analyzer algorithm case 1
x_{i} _{+ 1} = xi + 1; y_{i + 1} = y_{i} + m
Specified (x_{0}, y_{0}) = (1, 1)
1) x_{1} = x_{0} + 1 = 2
y_{1} = y_{0} + m = 1+ (6/8) = 7/4
Place pixel (x_{0}, round y, colour)
That is, put on (2, 2)
Likewise, go on until (9, 7) is arrived at.