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

Bresenham Line Drawing Algorithm

The document explains the Bresenham line drawing algorithm. It describes the steps to calculate the points between a starting and ending coordinate by calculating the change in X and Y values, a decision parameter, and generating subsequent points based on that parameter until the end is reached. It also provides examples of applying the algorithm to problems with different starting and ending coordinates.

Uploaded by

thoughts0976
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Bresenham Line Drawing Algorithm

The document explains the Bresenham line drawing algorithm. It describes the steps to calculate the points between a starting and ending coordinate by calculating the change in X and Y values, a decision parameter, and generating subsequent points based on that parameter until the end is reached. It also provides examples of applying the algorithm to problems with different starting and ending coordinates.

Uploaded by

thoughts0976
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

Bresenham Line Drawing Algorithm-

Procedure-

Given-

Starting coordinates = (X0, Y0)

Ending coordinates = (Xn, Yn)

The points generation using Bresenham Line Drawing Algorithm involves the
following steps-

Step-01:

Calculate ΔX and ΔY from the given input.

These parameters are calculated as-

ΔX = Xn – X0

ΔY =Yn – Y0

Step-02:

Calculate the decision parameter Pk.

It is calculated as-

Pk = 2ΔY – ΔX

Step-03:

Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).

Find the next point depending on the value of decision parameter Pk.

Follow the below two cases-


Step-04:

Keep repeating Step-03 until the end point is reached or number of iterations
equals to (ΔX-1) times.

PRACTICE PROBLEMS BASED ON BRESENHAM LINE DRAWING


ALGORITHM-

Problem-01:

Calculate the points between the starting coordinates (9, 18) and ending
coordinates (14, 22).

Solution-

Given-

Starting coordinates = (X0, Y0) = (9, 18)

Ending coordinates = (Xn, Yn) = (14, 22)

Step-01:

Calculate ΔX and ΔY from the given input.


ΔX = Xn – X0 = 14 – 9 = 5

ΔY =Yn – Y0 = 22 – 18 = 4

Step-02:

Calculate the decision parameter.

Pk = 2ΔY – ΔX

=2x4–5

=3

So, decision parameter Pk = 3

Step-03:

As Pk >= 0, so case-02 is satisfied.

Thus,

Pk+1 = Pk + 2ΔY – 2ΔX = 3 + (2 x 4) – (2 x 5) = 1

Xk+1 = Xk + 1 = 9 + 1 = 10

Yk+1 = Yk + 1 = 18 + 1 = 19

Similarly, Step-03 is executed until the end point is reached or number of iterations
equals to 4 times.

(Number of iterations = ΔX – 1 = 5 – 1 = 4)
Problem-02:

Calculate the points between the starting coordinates (20, 10) and ending
coordinates (30, 18)

Solution-

Given-

Starting coordinates = (X0, Y0) = (20, 10)

Ending coordinates = (Xn, Yn) = (30, 18)

Step-01:

Calculate ΔX and ΔY from the given input.

ΔX = Xn – X0 = 30 – 20 = 10

ΔY =Yn – Y0 = 18 – 10 = 8

Step-02:

Calculate the decision parameter.

Pk= 2ΔY – ΔX

= 2 x 8 – 10 = 6
So, decision parameter Pk = 6

Step-03:

As Pk >= 0, so case-02 is satisfied.

Thus,

Pk+1 = Pk + 2ΔY – 2ΔX = 6 + (2 x 8) – (2 x 10) = 2

Xk+1 = Xk + 1 = 20 + 1 = 21

Yk+1 = Yk + 1 = 10 + 1 = 11

Similarly, Step-03 is executed until the end point is reached or number of iterations
equals to 9 times.

(Number of iterations = ΔX – 1 = 10 – 1 = 9)

You might also like