2 DDA_line Drawing

download 2 DDA_line Drawing

of 6

description

gggggggggggggggggggfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

Transcript of 2 DDA_line Drawing

BRESENHAMS LINE ALGORITHMDDA line drawing algorithm is suffered by some limitations which have been removed in Bresenhams line drawing algorithm.To understand the concept first of all we consider the scan conversion process for lines with positive slope less than 1Starting from left end point(x0,y0) we scan horizontally at step size x=1 & plot the pixel whose scan line y value is closest to the line path foreg: we have just ploted the pixel at (xk,yk) and how we have to plot the next pixel

For next pixel we have two choices (xk+1,yk+1) or (xk+1,yk) now the y coordinate at the actual line position when x=xk+1 can be calculate as given below y=m(xk+1)+b actual valueNow, D1 =y-yk D1 = m(xk+1)+b-yk .............................................1eq D2 =yk+1-y D2 =yk+1-[m(xk+1)+b] .2eq Now d1 d2 =m(xk+1+b-yk (yk+1)+[m(xk+1)+b]= m(xk+1)+b-yk-yk-1+m(xk+1)+b=2m(xk+1) -2yk+2b-1A decision parameter pk for the kth step can be calculate as given belowPk = x[d1-d2]= x[2m(xk+1)-2yk+2b-1]OrPk= x[2y/x(xk+1)-2yk+2b-1]Pk=[2 y(xk+1)-2 xyk+2 xb-x]Pk=2yxk+2y-2xyk+2xb-x PK=2xky-2yk x+ceq 3Where c=2y+2xb-x If pK