6 - MidPoint Algorithm
6 - MidPoint Algorithm
Procedure-
Given-
Starting coordinates = (X0, Y0)
Ending coordinates = (Xn, Yn)
The points generation using Mid Point Line Drawing Algorithm involves the following steps-
Mid-Point Line Drawing Algorithm
Step-01:
Step-02:
Step-03:
The decision whether to increment X or Y coordinate depends upon the flowing values of
Dinitial.
Follow the below two cases-
Mid-Point Line Drawing Algorithm
Step-04:
Problem-01:
Calculate the points between the starting coordinates (20, 10) and ending coordinates (30,
18).
Solution-
Given-
Mid-Point Line Drawing Algorithm
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
20 10
6 2 21 11
Mid-Point Line Drawing Algorithm
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
Mid-Point Line Drawing Algorithm
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:
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
Mid-Point Line Drawing Algorithm
7 12 16