This action might not be possible to undo. Are you sure you want to continue?

Obtain the starting value for the decision parameter P0 =2 ¨y. At each xk along the line starting at k=0 perform the following test: if Pk<0 the next point to be plotted is (xk+1. Load (x0. Calculate constants ¨x. Input the two end points and store the left end point as (x0.yk) and pk+1=pk+2 ¨ y .2 ¨y and 2 ¨y-2 ¨x 4.y0) in to the frame buffer that is plot the first point 3.1. ¨2y.y0) 2.¨x 5.

yk) and pk+1=pk+2 ¨ y 6.yk+1) and pk+1=pk+2 ¨y-2 ¨x 7.5.Repeat step4 ¨x times . Else the next point is (xk+1. At each xk along the line starting at k=0 perform the following test: if Pk<0 the next point to be plotted is (xk+1.

In bresenhams algorithm we test the sign of an integer parameter whose value is proportional to the difference between the separation of the two pixel positions from the actual path .

Y=mx+b Yk+1 Y Yk D2 D1 Xk+1 .

The y coordinate on the mathematical line at pixel column position xk+1 is calculated as Y=m(xk+1)+b Then d1=y-yk d1=m(xk+1)+b-yk d2=(yk+1)-y d2=(yk+1)-(m(xk+1)+b) d2=(yk+1)-m(xk+1)-b .

(yk+1)+m(xk+1)+b = 2m(xk+1)+2b-2yk-1 Substitute m by ¨y/ ¨x And define pk= ¨x(d1-d2) .The difference between the two separations d1-d2= m(xk+1)+b-yk .

Pk= ¨x(2 ¨y/ ¨x(xk+1)+2b-2yk-1) Pk=2 ¨yxk-2 ¨xyk+c Where c= 2 ¨y+2 ¨xb.¨x = 2 ¨y+ ¨x(2b-1) Pk has the sign of d1-d2 .

If pixel at yk is closer to the line path than the pixel at yk+1 (ie if d1<d2) then decision parameter pk is negative In that case we plot the lower pixel else we plot the upper pixel. .

2 ¨x(yk+1 ±yk) Since xk+1 =xk+1 Pk+1-pk=2 ¨y .2 ¨x(yk+1 ±yk) Pk+1=pk+2 ¨y .At any step k+1 the decision parameter is evaluated as Pk+1= 2 ¨yxk+1-2 ¨xyk+1+b Pk+1-pk=2 ¨y(xk+1 ±xk) .2 ¨x(yk+1 ±yk) .

p0 is calculated as P0 = 2 ¨y.For any line .¨x .

while x<xend do begin x=x+1.y. p=2*dy-dx.y.xb. xend=xa.yb:integer).y. y=ya. if xa>xb then begin x=xb.1).ya. begin dx=abs(xa-xb). p=p+2*(dy-dx) end setpixel(x.xend. if p<0 then p=p+2 *dy else begin y=y+1. y=yb. end setpixel(x.1) end end .p:integer. xend=xb. end else begin x=xa.x.procedure linebres(xa. Var dx.dy. dy=abs(ya-yb).

Calculate constants ¨x. Input the two end points and store the left end point as (x0.1. Obtain the starting value for the decision parameter P0 =2 ¨y. At each xk along the line starting at k=0 perform the following test: if Pk<0 the next point to be plotted is (xk+1.¨x 5. Load (x0.2 ¨y and 2 ¨y-2 ¨x 4. ¨2y.yk) and pk+1=pk+2 ¨ y .y0) in to the frame buffer that is plot the first point 3.y0) 2.

Repeat step4 ¨x times .yk+1) and pk+1=pk+2 ¨y-2 ¨x 7.5. Else the next point is (xk+1.yk) and pk+1=pk+2 ¨ y 6. At each xk along the line starting at k=0 perform the following test: if Pk<0 the next point to be plotted is (xk+1.

Tracing of the algorithm Draw a line with end points(20.18) The slope of the line is 0.10) and (30.8 dx=10 dy=8 Initial parameter P0 has the value = 2¨y .¨x =6 Increments for the successive decision parameters are 2¨y=16 2¨y-2¨x=-4 .

16 28.13 25.k 0 1 2 3 4 5 6 7 8 9 pk 6 2 -2 14 10 6 2 -2 14 10 xk+1.12 23.17 30.18 .yk+1 21.12 24.11 22.15 27.14 26.16 29.

y0) .Circle generating algorithm Circle is defined as the set of points that are all at a given distance r from the center position (x0.

Uploaded by zohaibmanna

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd