Bresenham Line Drawing Algorithm

Preview:

DESCRIPTION

The Bresenham algorithm is another incremental scan conversion algorithm. It is useful alternative for the DDA The big advantage of this algorithm is that it uses only integer calculations

Citation preview

Bresenham Line Drawing Algorithm

බ්‍රි�සන්හෙ�ම් හෙ� සරල හෙ�ඛා නි�මා ණය සඳ� වූ

ඇල්හෙ� රිතමාය

The Bresenham algorithm is another incremental scan conversion algorithm. It is useful alternative for the DDAThe big advantage of this algorithm is that it uses only integer calculations

Let’s take following example If starting point is (2,2)and ending point of line is (7,4) calculate the first 3 points of the line by using Bresenham algorithm

First of all we take first plot of the above line as (2,2) Then we need to calculate constant of followingΔx => 7-2=5Δy => 4-2=22Δy => 42Δx =>102Δy – Δx => 4-5=-12Δy -2Δx=> 4-10=-6

Then we need to find p1 for plot the second plot of the line

P1= 2Δy – Δx P1= 4-5=-1P1<0 then we are not increasing y from 1(always x increase from 1)Second plot is (3,2)

Use to find P1

Then we need to find p2 for plot the second plot of the line

When the P1 is less than 1 we use following algorithm to find the next plotP2= P1 +2Δy P2= -1 + 4=3

In this time P2>0 then we increase y from 1(always x increase from 1)Second plot is (4,3)

If P1<0 we use flowing equation to find P2

Then we need to find p3 for plot the third plot of the line

When the P2 >0 we use following algorithm to find the next plotP3= P2 +2Δy - 2ΔxP3= 3+ 4-10=-3In this time P3<0 then we are not increasing y from 1(always x increase from 1)Third plot is (5,3)

If P2>0 we use flowing equation to find P3

10 2 3 4 5 6 7

1

2

3

4

5

6

7

If we take it up to final plots our plots will show as (2,2)(3,2)(4,3)(5,3)(6,4)(7,4)

Recommended