Mid Point Line Drawing Algorithm
Mid Point Line Drawing Algorithm
Procedure-
Given-
Starting coordinates = (X0, Y0)
Ending coordinates = (Xn, Yn)
The points generation using Mid Point Line Drawing Algorithm involves the following steps-
Step-01:
Step-02:
The decision whether to increment X or Y coordinate depends upon the flowing values of Dinitial.
Follow the below two cases-
Step-04:
Problem-01:
Calculate the points between the starting coordinates (20, 10) and ending coordinates (30, 18).
Solution-
Given-
Starting coordinates = (X0, Y0) = (20, 10)
Ending coordinates = (Xn, Yn) = (30, 18)
Step-01:
Step-02:
Step-03:
Thus,
Xk+1 = Xk + 1 = 20 + 1 = 21
Yk+1 = Yk + 1 = 10 + 1 = 11
Dnew = Dinitial + ΔD = 6 + (-4) = 2
Similarly, Step-03 is executed until the end point is reached.
20 10
6 2 21 11
2 -2 22 12
-2 14 23 12
14 10 24 13
10 6 25 14
6 2 26 15
2 -2 27 16
-2 14 28 16
14 10 29 17
10 30 18
Problem-02:
Calculate the points between the starting coordinates (5, 9) and ending coordinates (12, 16).
Solution-
Given-
Starting coordinates = (X0, Y0) = (5, 9)
Ending coordinates = (Xn, Yn) = (12, 16)
Step-01:
Step-02:
Step-03:
Thus,
Xk+1 = Xk + 1 = 5 + 1 = 6
Yk+1 = Yk + 1 = 9 + 1 = 10
Dnew = Dinitial + ΔD = 7 + 0 = 7
5 9
7 7 6 10
7 7 7 11
7 7 8 12
7 7 9 13
7 7 10 14
7 7 11 15
7 12 16