Digital Differential Algorithm (DDA)
Basic Concept
• It is an incremental method of scan conversion of line.
• In this method, calculation is performed at each step using results of previous
steps.
• In DDA, we analyze difference in pixel points to generate a line.
DDA (Continuation)
Slope Properties
• Slope of a given line can be positive or negative.
• If slope is positive, then Δx and Δy values increase.
• If slope is negative, then Δx and Δy values decrease.
• Positive slope means m > 0.
• Negative slope means m ≤ 0.
DDA Line Drawing Algorithm
Step-by-Step Procedure
1. Read the input of start and end point coordinates
i.e.
𝐴(𝑥1 , 𝑦1 )&𝐵(𝑥2 , 𝑦2 )
2. Calculate differences
𝑑𝑥 = 𝑥2 − 𝑥1
𝑑𝑦 = 𝑦2 − 𝑦1
3. If dx > dy then
𝑘 = 𝑑𝑥
else
𝑘 = 𝑑𝑦
4. Calculate incremental values
𝑑𝑥 = 𝑑𝑥/𝑘
𝑑𝑦 = 𝑑𝑦/𝑘
5. Initialize
𝑋 = 𝑥1 , 𝑌 = 𝑦1
6. Display pixel (X, Y)
7. Update coordinates
𝑋 = 𝑋 + 𝑑𝑥
𝑌 = 𝑌 + 𝑑𝑦
8. Display rounded value of pixel (X, Y)
9. Repeat step 7 and 8 k times
(until end point is reached)