DDA Line Drawing Algorithm
Learn and visualize the DDA Line Drawing Algorithm with our interactive tool. Perfect for students and developers exploring computer graphics and algorithm implementation
Step-by-Step Calculation of DDA
Starting Points (X1, Y1) = (1, 1)
Ending Points (X2, Y2) = (5, 5).
Step 1: Calculate Dx, Dy, and Slope(m)
Dx = abs(X2−X1) = |5 - 1| = 4
Dy = abs(Y2−Y1) = |5 - 1| = 4
Slope(m) = Dx/Dy = 4 / 4 = 1
Step 2: Calculating the Number of Steps
Dx = 4 and Dy = 4
Then, the number of steps = 4
Step 3: We get m = 1, Third case is Satisfied
Then X and Y coordinate tend to the Unit interval.
X = X + 1
Y = Y + 1
Initial values: X = 1, Y = 1
Iteration: 1
X = 1 + 1 = 1 and Y = 1 + 1 = 1
Iteration: 2
X = 2 + 1 = 2 and Y = 2 + 1 = 2
Iteration: 3
X = 3 + 1 = 3 and Y = 3 + 1 = 3
Iteration: 4
X = 4 + 1 = 4 and Y = 4 + 1 = 4
DDA Algorithm Case
Case 1: If m < 1
Then x coordinate tends to the Unit interval.
- xk+1 = xk + 1
- yk+1 = yk + m
Case 2: If m> 1
Then y coordinate tends to the Unit interval.
- yk+1 = yk + 1
- xk+1 = xk + 1/m
Case 3: If m = 1
Then x and y coordinate tend to the Unit interval.
- xk+1 = xk + 1
- yk+1 = yk + 1
Table View
| Step | X Value | Y Value | Dx | Dy | X Increment | Y Increment | Calculation |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 4 | 4 | 1 | 1 | Initial values: X = 1, Y = 1 |
| 1 | 1 | 1 | 4 | 4 | 1 | 1 | X = 1 + 1 = 1 and Y = 1 + 1 = 1 |
| 2 | 2 | 2 | 4 | 4 | 1 | 1 | X = 2 + 1 = 2 and Y = 2 + 1 = 2 |
| 3 | 3 | 3 | 4 | 4 | 1 | 1 | X = 3 + 1 = 3 and Y = 3 + 1 = 3 |
| 4 | 4 | 4 | 4 | 4 | 1 | 1 | X = 4 + 1 = 4 and Y = 4 + 1 = 4 |