Bresenham Line Drawing Algorithm

3,108 views

Published on

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

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,108
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
83
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Bresenham Line Drawing Algorithm

  1. 1. Bresenham Line Drawing Algorithm බ්‍රිසන්හෙම් හේ සරල හේඛා නිේමාණය සඳො වූ ඇල්හ ොරිතමය
  2. 2. 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 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
  3. 3. 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=2 2Δy => 4 2Δx =>10 2Δy – Δx => 4-5=-1 2Δy -2Δx=> 4-10=-6
  4. 4. Then we need to find p1 for plot the second plot of the line P1= 2Δy – Δx P1= 4-5=-1 P1<0 then we are not increasing y from 1(always x increase from 1) Second plot is (3,2) Use to find P1
  5. 5. 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 plot P2= 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
  6. 6. 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 plot P3= P2 +2Δy - 2Δx P3= 3+ 4-10=-3 In 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
  7. 7. 10 2 3 4 5 6 7 1 2 3 4 5 6 7
  8. 8. 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)

×