![]() ( DDA uses repeated addition ) ( Use of floating point operations makes it slightly slower than Bresenham's Algo ) Explanation: The program should make use of basic concept of DDA’s line generation algorithm. The DDA is a scan conversion line algorithm based on calculating Dy and Dx. We sample the line at unit intervals in one co-ordinate and determine corresponding integer values nearest the line path for the other co-ordinate.1. We will consider a line with positive slope. >>If the slope is less than or equal to 1,we sample it at unit x intervals (Dx = 1) and compute each successive y value as yk+1 = yk + m (Subscript k takes integer values starting from 1 for the first point and increases by 1 until the final end point is reached. The value of m can be any real number between 0 and 1.2) >>For lines with positive slope greater than 1, we reverse the roles of x and y. We sample at unit y intervals and calculate each succeeding x value as xk+1= xk + 1/m >> For the above equation we are processing the line equation from the left end point to right end point. If this processing is reversed , (negative Slope) so either we have Dx = -1 and
yk+1 = yk - m Or Dy = -1 and xk+1= xk - 1/m Program:
|