To draw a line, you need two points between which you can draw a line. The Bresenham algorithm is another incremental scan conversion algorithm. The big . E Claridge, School of Computer Science, The University of Birmingham. DERIVATION OF THE BRESENHAM’S LINE ALGORITHM. Assumptions: ○ input: line. The basic ”line drawing” algorithm used in computer graphics is Bresenham’s example, in which we wish to draw a line from (0,0) to (5,3) in device space.

Author: | Moogugami Aragor |

Country: | Cyprus |

Language: | English (Spanish) |

Genre: | Sex |

Published (Last): | 8 January 2008 |

Pages: | 51 |

PDF File Size: | 2.86 Mb |

ePub File Size: | 9.23 Mb |

ISBN: | 877-3-79624-232-5 |

Downloads: | 78023 |

Price: | Free* [*Free Regsitration Required] |

Uploader: | Yozshugrel |

Bresenham’s line aogorithm is an algorithm that determines the points of an n -dimensional raster that should be selected in order to form a close approximation to a straight line between two points. It is lihe used to draw line primitives in a bitmap image e. It is an incremental error algorithm. It is one of the earliest algorithms developed in the field of computer graphics. An extension to the original algorithm may be used for drawing circles. While algorithms such as Wu’s algorithm are also frequently used in modern computer graphics because they can support antialiasingthe speed and simplicity of Bresenham’s line algorithm means that it is still important.

Breseham algorithm is used in hardware such as plotters and in the graphics chips of modern graphics cards. It can bresenhzm be found in many software graphics libraries. Because the algorithm is very simple, it is often implemented in either the firmware or the graphics hardware of modern graphics cards. The label “Bresenham” is used today for a family of algorithms extending or modifying Bresenham’s original algorithm.

In Bresenham wrote: A Calcomp plotter had been attached to an IBM via the typewriter console. Programs in those days were freely exchanged among corporations so Calcomp Jim Newland and Calvin Hefte had copies. A description of the line drawing routine was accepted for presentation at the ACM national convention in Denver, Colorado. It was a year in which no proceedings were published, only the agenda of speakers and topics in an issue of Communications of the ACM. I happily agreed, and they printed it in Bresenham’s algorithm was later extended drawinb produce circles, the resulting algorithms being ‘Bresenham’s circle algorithm and midpoint algorlthm algorithm.

### Computer Graphics Line Generation Algorithm

Bresenham’s algorithm chooses the integer y corresponding to the pixel center that is closest to the ideal fractional y for the same x ; on successive columns y can remain the same or increase by 1.

The general equation of the line through the endpoints is given by:. Since linw know the column, xthe pixel’s row, yis given by rounding this quantity to the nearest integer:. If the error becomes greater than 0.

In the following pseudocode sample plot x,y plots the pixel centered at coordinates x,y and abs returns absolute value:. To derive Bresenham’s algorithm, two steps must be taken. The first step is transforming the equation of a line from the typical slope-intercept form into something different; and then using this new equation for a line to draw a line based on the idea of accumulation of error. This is a function of only x and it would be useful to make drawint equation written as a function of both x and y.

It should be noted that everything about this form involves only integers if x and y are integers since the constants are necessarily integers. The point 2,2 is on the line. Notice alogrithm the points 2,1 and 2,3 are on opposite sides of the line and f x,y evaluates to positive or negative. A line splits a plane into halves and the half-plane that has a negative f x,y can be called the negative half-plane, and the other half can be called the positive half-plane.

This observation is very important in the remainder of the derivation. If it is closer to the former then include the former point on the line, if the latter then the latter. To answer this, evaluate the line function at the midpoint between these two points:.

draiwng This observation is crucial to understand! The value of the line function at this midpoint is the sole determinant of which point should be chosen. The adjacent image shows the blue point 2,2 chosen to be on the line with two candidate points in green 3,2 and 3,3. The black point 3, 2. Alternatively, the difference between points can be used instead of evaluating f x,y at midpoints. This alternative method allows for integer-only arithmetic, which is generally faster than using floating-point arithmetic.

To derive the alternative method, define the difference to be as follows:. Simplifying this expression yields:. This decision can be generalized by accumulating the error.

All of the derivation for the algorithm is done. Since all of this is about the sign of the accumulated difference, then everything can be multiplied by 2 with no consequence. The result of this plot is shown to the right.

The plotting can be viewed by plotting at the intersection breenham lines blue circles or filling in pixel boxes yellow squares. Regardless, the plotting is the same. However, as mentioned above this is only dtawing octant zero, that is lines starting at the origin with a gradient between 0 and 1 where x increases by exactly 1 per iteration and y increases by 0 or 1.

The algorithm can be extended to cover gradients between 0 and -1 by checking whether y needs to increase or decrease i. By switching the x and y axis an implementation for positive or negative steep gradients can be written as.

## Bresenham’s line algorithm

Gresenham low level implementation which access the video memory directly it would be typical for the special cases of vertical and horizontal lines to be handled separately as they can be highly optimised.

The Bresenham algorithm can be interpreted as slightly modified digital differential analyzer using 0. The principle of using an incremental error in place of division operations has other applications in graphics. It is possible to use this technique to calculate the U,V co-ordinates during raster scan of texture mapped polygons [ citation needed ].

The voxel heightmap software-rendering engines seen in some PC games also used this principle. Bresenham also published a Run-Slice as opposed to the Run-Length computational algorithm.

From Wikipedia, the free encyclopedia. This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. August Learn how and when to remove drawiing template message.

Retrieved 20 December Retrieved from ” https: Computer graphics algorithms Digital geometry. Articles needing additional references from August All articles needing additional references All articles with unsourced statements Articles with unsourced statements from September Articles with unsourced statements from December All Wikipedia articles needing clarification Wikipedia articles needing clarification from May Commons category link is on Algorithmm Articles with example pseudocode.

Views Read Edit View history. In other projects Wikimedia Commons. This page was last edited on 16 Octoberat By using this site, you agree to the Terms of Use and Privacy Policy.

Wikimedia Commons has media related to Bresenham algorithm.