DDA Algorithm
DDA Algorithm
DDA Algorithm-
DDA Algorithm is the simplest line drawing algorithm.
Given-
The points generation using DDA Algorithm involves the following steps-
Step-01:
ΔX = Xn – X0
ΔY =Yn – Y0
M = ΔY / ΔX
Step-02:
Find the number of steps or points in between the starting and ending coordinates.
else
Step-03:
Suppose the current point is (Xp, Yp) and the next point is (Xp+1, Yp+1).
[Type text]
Step-04:
Keep repeating Step-03 until the end point is reached or the number of generated
new points (including the starting and ending points) equals to the steps count.
Problem-01:
Calculate the points between the starting point (5, 6) and ending point (8, 12).
Solution-
Step-01:
ΔX = Xn – X0 = 8 – 5 = 3
ΔY =Yn – Y0 = 12 – 6 = 6
M = ΔY / ΔX = 6 / 3 = 2
Step-02:
Step-03:
Calculate the points between the starting point (5, 6) and ending point (13, 10).
[Type text]
Step-01:
ΔX = Xn – X0 = 13 – 5 = 8
ΔY =Yn – Y0 = 10 – 6 = 4
M = ΔY / ΔX = 4 / 8 = 0.50
Step-02:
Step-03:
Problem-03:
Calculate the points between the starting point (1, 7) and ending point (11, 17).
Solution-
Given-
Step-01:
ΔX = Xn – X0 = 11 – 1 = 10
ΔY =Yn – Y0 = 17 – 7 = 10
M = ΔY / ΔX = 10 / 10 = 1
Step-02:
Step-03:
As M = 1, so case-02 is satisfied.