C Program To Generate Line Using Dda Algorithm

It is an incremental scan-conversion line drawing algorithm. The calculations performed at every increment is based on the previous increment. To draw any line in computer graphics, you need two coordinates on a 2-dimensional planar surface. Every line will have the start point (X 0, Y 0) and end point (X 1, Y 1). For drawing a DDA line, we cannot directly connect the start and end points. We have to calculate intermediate point’s coordinate. Then, we have to insert an increment for each intermediate point on the line.

Virginia jacob de haan pdf. In this algorithm, we need to use floating-point arithmetic and it can use multiplication and division operations. This algorithm is a faster method for calculating the positions of the pixels.

There are, however, a lot of disadvantages with this line drawing algorithm. It is not very efficient when it comes to optimisation.

C program to generate line using dda algorithm program

It is not accurate as compared to other line drawing algorithms. The c program for DDA line drawing algorithm rounds off the line coordinates to an integer which is an approximation to the expected line. However, the round operations in the algorithm are too inefficient. There are several other line drawing algorithms that are much more efficient and accurate than DDA algorithm such as.

Float x,y,x1,y1,x2,y2,dx,dy,step; int i,gd=DETECT,gm; initgraph(&gd,&gm,'c: turboc3 bgi'); printf('Enter the value of x1 and y1: '); scanf('%f%f',&x1,&y1); printf('Enter the value of x2 and y2: '); scanf('%f%f',&x2,&y2). It is a highly efficient incremental method to scan and convert the lines as compared to the DDA line drawing algorithm. However, it requires the line coordinates to be of integer type. However, it requires the line coordinates to be of integer type.