0% found this document useful (0 votes)
10 views

Bresenham Line Drawing Algorithm

Uploaded by

tazusamamiya2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Bresenham Line Drawing Algorithm

Uploaded by

tazusamamiya2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Bresenham’s Line Drawing Algorithm

2: Bresenham’s line algorithm is an algorithm which determines which order to form a close approximation to
a straight line between two given points. Write a C program for determining pixel activation list between two
given points in order to draw line segment using bresenham’s Line drawing algorithm?

Aim: To implement Bresenham’s line drawing algorithm for drawing a line segment between two
given endpoints A (x1, y2) and B(x2, y2).

Description:
Basic Concept:
 Move across the x axis in unit intervals and at each step choose between two
different y coordinates

 For example, from position (2, 3) we have to choose between (3, 3) and (3, 4). We
would like the point that is closer to the original line

 So we have to take decision to choose next point. So next pixels are selected based
on the value of decision parameter p. The equations are given in below algorithm.

Algorithm:

BRESENHAM’S LINE DRAWING ALGORITHM

1. Input the two line end-points, storing the left end-point in (x0, y0)

2. Plot the point (x0, y0)

3. Calculate the constants Δx, Δy, 2Δy, and (2Δy - 2Δx) and get the first value for the decision
parameter as:

p0  2 y  x
4. 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:

p k  1  p k  2  y

Otherwise, the next point to plot is (xk+1, yk+1) and:

p k  1  p k  2  y  2  x
5. Repeat step 4 (Δx – 1) times
NOTE: The algorithm and derivation above assumes slopes are less than 1. For other slopes we
need to adjust the algorithm slightly

You might also like