written 8.3 years ago by | • modified 8.3 years ago |
Mumbai university > Comp > SEM 4 > Computer Graphics
Marks: 10M
Year: Dec 2014,Dec 2015
written 8.3 years ago by | • modified 8.3 years ago |
Mumbai university > Comp > SEM 4 > Computer Graphics
Marks: 10M
Year: Dec 2014,Dec 2015
written 8.3 years ago by |
Bresenham Algorithm was developed by J. E. Bresenham in 1962.
It is much accurate and much more efficient than DDA.
It scans the coordinates but instead of rounding them off it takes the incremental value in account by adding or subtracting and therefore can be used for drawing circle and curves.
Therefore if a line is to be drawn between two points x and y then next coordinates will be $(x_{a+1}, y_a)$ and $(x_{a+1}, y_{a+1})$.
Where ‘a’ is the incremental value of the next coordinates and difference between these two will be calculated by subtracting or adding the equations formed by them.
Bresenhams line draw algorithm for lines with slope < 1:
Accept two endpoints from user and store the left end point in (x0, y0) as starting point.
Plot the point $(x_0, y_0)$.
Calculate the constants Dx, Dy, 2Dy, 2Dy – 2Dx and obtain the starting value for the decision parameter as G = 2Dy- Dx.
For each column increment X and decide Y value by checking G > 0 condition.
If it is true then increment Y value and add (2Dy – 2Dx) to current value of G.
Otherwise add 2Dy to G and don’t increment Y value.
Plot next point. See figure 6.
Repeat the step iv till Dx times.
For steep slope cases just interchange the rolls of X and Y i.e. we step along the Y direction in unit steps and calculate successive X values nearest the line path.
If the initial position for a line with positive slope is right endpoint, as shown in figure 7, then we have to decrease both X and Y as we step from right to left.