Explain DDA (Digital Differential Analyzer) Scan Conversion Algorithm?
The digital differential analyzer is a scan conversion algorithm based on calculation either y or x using the following equations:
y = m * x
x = y / m
Sample the line at unit intervals in one coordinate and determine corresponding integer values nearest the line path for the coordinates
Sample at X intervals ( x = 1) and compute each successive Y value as Yk+1 = Yk + m
For lines with positive slope greater than 1, reverse the roles of X and Y.
Sample at unit Y intervals ( y = 1) and calculate each successive X value as
Xk+1 = Xk + 1/m
Algorithm Step by Step
Step 1: Input the line endpoints and store the left endpoint in (x1, y1) and right endpoint in (x2, y2)
Step 2: Calculate the values of x and y using x = xb – xa, y = yb – ya
Step 3: if the values of x > y assign values of steps as x otherwise the values of steps as y
Step 4: Calculate the values of X increment and Y increment and assign the value x= xa and y = ya
Step 5: for k=1 to steps do X = X + X
increment Y= Y + Y increment
Putpixel(ceil(x), ceil(y),15)
Step 6: End