2
7/21/2019 Example on Bresenhams line drawing algorithm http://slidepdf.com/reader/full/example-on-bresenhams-line-drawing-algorithm 1/2 Example: Consider the line from (0, 0) to (-8,- 4), use general Bresenham’s line algorithm to rasterize this line. Evaluate and tabulate all the steps involved. Solution: Given data, (x 1 , y 1 )= (0, 0) (x 2 , y 2 )= (-8,-4) x=x 2 -x 1 =-8-0=8  S 1 =-1 y=y 2 -y 1 =-4-0=4 S 2 =-1 Decision Variable=e=2*(y)-(x) e= 2*(4)-(8) =8-8 =0 By using general Bresenham’s algorithm,  The result in tabulated form as, Pixel e x y Initially (0,0) 0 0 0 (-1,0) +8 -1 0 (-2,-1) 0 -2 -1 (-3,-1) -8 -3 -1 (-4,-2) 0 -4 -2 (-5,-2) +8 -5 -2 (-6,-3) 0 -6 -3 e=0

Example on Bresenhams line drawing algorithm

Embed Size (px)

DESCRIPTION

Numerical on Bresenham's line drawing algorithm with step by step form..

Citation preview

Page 1: Example on Bresenhams line drawing algorithm

7/21/2019 Example on Bresenhams line drawing algorithm

http://slidepdf.com/reader/full/example-on-bresenhams-line-drawing-algorithm 1/2

Example: Consider the line from (0, 0) to (-8,-4), use general Bresenham’s line algorithm to

rasterize this line. Evaluate and tabulate all the steps involved.

Solution:

Given data,

(x1, y1)= (0, 0)

(x2, y2)= (-8,-4)

∆x=x2-x1=-8-0=8

∴ S1=-1

∆y=y2-y1=-4-0=4

∴S2=-1

Decision Variable=e=2*(∆y)-(∆x)

∴e= 2*(4)-(8)

=8-8 =0

By using general Bresenham’s algorithm, 

The result in tabulated form as,

Pixel e x y

Initially (0,0) 0 0 0

(-1,0) +8 -1 0

(-2,-1) 0 -2 -1

(-3,-1) -8 -3 -1

(-4,-2) 0 -4 -2

(-5,-2) +8 -5 -2

(-6,-3) 0 -6 -3

e=0

Page 2: Example on Bresenhams line drawing algorithm

7/21/2019 Example on Bresenhams line drawing algorithm

http://slidepdf.com/reader/full/example-on-bresenhams-line-drawing-algorithm 2/2

(-7,-3) +8 -7 -3

(-8,-4) 0 -8 -4

∴ By pictorial presentation in graph is as shown below,

--- This is required solution for the given line using Bresenham’s algorithm. 

(0, 0) -1 -2 -3 -4 -5 -6 -7 -8

-1

-2

-3

-4

-5

-6