What is DDA Algorithm?
Digital differential Analyzer is a line drawing algorithm which calculates and plots coordinates on the basis of the previously calculated intermediate points until it reaches to the final point. However, this algorithm works on the concept of the slope-intercept equation.
- Since, A line segment has an initial point (x0,y0) and a final point (x1,y1), so get the input from the user regarding initial and final point.
- After getting the input, calculate the value of Δx and Δy. (Δ represents the difference between two points) Δx= x1-x0, Δy= y1-y0
- Find the slope of the line by usin.g: Slope =Δy/Δx
- if Slope > 1 then do,
While x isn’t equivalent to the final point (x1) do,
x0+k = xk + (1/m)
While y isn’t equivalent to the final point (y1) do,
y0+k = yk + (m), x=x+1
C program to draw a line using DDA algorithm in computer graphics
printf("\n please enter the initial points of x, y = ");
printf("\n enter the final points of x, y = ");
You must be logged in to take the quiz.