You are on page 1of 2

DDA LINE GENERATING ALGORITHM:

Digital Differential Analyzer is scan conversion line algorithm based on calculations on dx


or dy.
In this method for finding next coordinate,
- we increment one part i.e x or y coordinate by 1 and find its corresponding remaining
coordinate using the equation.
Now the question arises which coordinate to increment and which to derive from the
equationthis can be decided by slope of the line
1)Now if the slope is steep it will map very less points on x-axis but a lot of points on yaxis thus here we increment y(next)=y(old)+1 and x(next) is obtained form the equation
discussed ahead,
2).Similiarly for line with low slope it will map less points on y-axis but has a lot of
points on x-axis thus here we increment x(next)=x(old)+1 and y(next) is obtained form the
equation discussed ahead .

Consider a line l with positive slope,


Then there are two cases:
For m>1 (case 1)

i.e. dy>dx

x(new)=x(old)+1;
y(new)=y(old)+m;
putpixel(x(new),y(new));

for m<1(case 2)

i.e.dy<dx

y(new)=y(old)+1;
1

x(new)=x(old)+ ;
putpixel(x(new),y(new));
IN the above eqns as m can have floating values we have to round off the x(new) and y(new)
values.
Thus here we floor the values using floor() function in C/C++.

Advantages:

It provides faster method than using the y=mx+c eqn for plotting

It is faster than raster scan


Disadvantages:

The round off operations causes roundoff erros which may cause deviation from actual
line path thus hinders the accuracy.

You might also like