Bresenham’s Line Algorithm
Bresenham’s Line Algorithm: The Bresanhan’s
Line Algorithm is one of the scan line algoirthm. The big advantege
of Bresanham’s line Algorithm is that it is use only integer calculation.
Algorithm :
step1 : input two
end point of line,showing the left end point
A(X0 , Y0) and B(X1 , Y1)
step2 : plot the
point (X0 , Y0)
Step3 : Calculate dx
, dy, 2dx , 2dy and 2dx – 2dy
dx = X1 -X0
dy = Y1 –
Y0
2dx = 2(
x1 -x0 )
2dy = 2(
Y1 – Y0 )
Po = 2dy – dx
step 4 :
taking k= 0 ;
if (Pk <0 )
then next point
is ( Xk+i , y1) ;
and Pk+1 = Pk + 2dy
;
else
point is (Xk ,
Yk+i)
Pk+1 = pk + 2(dx –
dy )
step5 : Repeat step
4 (dx -1) times
Comments
Post a Comment