Advantage & Disadvantage of DDA Algo
Advantage & Disadvantage of DDA Algo
Advantage & Disadvantage of DDA Algo
Adva
It is a faster method for calculating pixel positions than the direct use.
Starting from the left end point(x0,y0) of a given line, we step to each successive column (x position) and plot the pixel whose scan line y value is closest to the line path.
y = m(x+1) + b y
d2
d1
x+1
Assume the given endpoints are (xa,ya) and (xb,yb), that xa < xb. Define x = xb - xa; y = yb - ya;
As in the DDA algorithm we will iterate through the relevant columns and set one pixel in each column.
Then in the next iteration xk+1,,, ,We will select either (xk+1,yk) or (xk+1,yk+1)
The y coordinate on the mathematical line at pixel position xk+1 is calculated as Y = m(Xk+1) + b
d1=y yk
= m(xk+1)+b - yk
d2=(yk+1)-y
=yk+1 m(xk+1)-b
But xk+1=xk+1
-[ 2 yxk
2
-2
xyk
+c
y -2
x(yk+1 yk)
We plot initial point (20 , 10) and determine successive pixel position along the line path from the decision parameters as
K 0 1 2 3 4 5
Pk 6 2 -2 14 10 6
Pk 2 -2 14 10
Bresenhams algorithm uses integer arithmetic Constants need to be computed only once
Bresenhams algorithm generally faster than DDA
else{ x = xa; y = ya; xEnd=xb; } setPixel(x,y); While (x < xEnd){ x++; If (p<0) p += twoDy; Else{ y++; p += twoDyDx;} Setpixel(x,y); } }