CGMM | Bresenham’s Line Generation Algorithm | Exp 3

Bresenham’s Line Generation Algorithm


The Bresenham algorithm is another incremental scan conversion algorithm. The big advantage of this algorithm is that, it uses only integer calculations. Moving across the x axis in unit intervals and at each step choose between two different y coordinates.


Working of Bresenham's Algorithm

1. Get the end coordinates of the line i.e. A(x1, y1) & B(x2, y2).
2. Calculate dx and dy.

dx = x2 - x1                                                                                                                        dy = y2 - y1   
3. Now calculate initial parameters (pk).

pk = 2*dy - dx
4. Now check valye of pk.
    If  pk < 0 :
pk = pk + 2*dy                                                                                                                Plotting points: (x+1, y)
   If pk > 0:
 pk =pk + 2*dy - 2*dx                                                                                                  Plotting points: (x+1, y+1)
5. Repeat until plotting points becomes (x2, y2).

Problem Statement

Bresenham’s Line Drawing algorithm is used for line drawing. How it removes the disadvantages of DDA line drawing algorithm.

2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete

Powered by Blogger.