1.C] Explain the DDA line drawing algorithm with its procedure
Digital Differential Analyzer (DDA) Algorithm
1. Slope Calculation
Slope (m): The slope of the line between two points (x1, y1)
and (x2, y2)
is calculated using the formula:
m = (Δy / Δx) = (y2 – y1) / (x2 – x1)
2. Finding Δx and Δy
Δx and Δy: The change in x (Δx) and the change in y (Δy) can be computed depending on the slope m
and the coordinates of the points.
The formula for Δx is derived as follows:
Δx = Δy / m = (x2 – x1) / (y2 – y1) * Δy = x2 – x1
The formula for Δy is:
Δy = y2 – y1
Another formula for Δy derived from the slope m
and Δx
is:
Δy = m * Δx = (y2 – y1) / (x2 – x1) * Δx = y2 – y1
3. Decision Rules for Incrementing Points
If |Δx| ≥ |Δy|:
- In this case,
x
is incremented by 1: - The next x-coordinate (
xi+1
) is: - The next y-coordinate (
yi+1
) is:
Δx = 1
xi+1 = xi + Δx = xi + 1
yi+1 = yi + Δy = yi + m * Δx = yi + m
If |Δx| < |Δy|:
- In this case,
y
is incremented by 1: - The next x-coordinate (
xi+1
) is: - The next y-coordinate (
yi+1
) is:
Δy = 1
xi+1 = xi + Δx = xi + Δy / m = xi + 1 / m
yi+1 = yi + Δy = yi + 1
Answer:
Example:-