Bre

You might also like

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 7

BRESENHAM

ALGORITHM

Step1 Input the two line end points and store the left endpoints in (x0, y0)

Step2 Load (x0, y0) into the frame buffer; plot the first point.

Step3 Calculate constants ∆x, ∆y, 2∆y, and 2∆y - 2∆x, and

obtain the starting value for the decision parameter as

∆x = xn - x0 and
∆y = yn - y0

p0 = 2∆y - ∆x

Step4 At each xk along the line, starting at k = 0, perform the following test:

If pk < 0, the next point to plot is

(xk+1, yk) and

pk+1 = pk +2∆y

Otherwise, the next point to plot is

(xk+1, yk+1) and

pk+1 = pk +2∆y -2∆x

Step5 Repeat step 4 ∆x times.


dx=x2-x1;
1.dy=y2-y1;
2.if(abs(dx)>abs(dy))
3.length=abs(dx);
4.else
5.length=abs(dy);
6.xinc=dx/(float)length;
7.yinc=dy/(float)length;
8.x=x1
9.y=y1
10.putpixel(x,y,10);
11.for(i=0;i<length;i++)
12.{
13.putpixel(x,y,10);
14.x=x+xinc;
15.y=y+yinc;
16.delay(10);
CALCULATION

HOW TO FIND MIDDLE POINT

You might also like