Computer graphics – bresenham line drawing algorithm DERIVATION • Starting from the left endpoint (x0, y0) of a given line, we step to each. Assumption: Y=mX+b where b is the intercept cut by line at Y axis and m is the slope of line (0 Derivation: Initially we have plotted a. To derive Bresenham’s algorithm, two steps must be taken. and then using this new equation for a line to draw a line based on the.

 Author: Dolabar Toshakar Country: United Arab Emirates Language: English (Spanish) Genre: Automotive Published (Last): 8 June 2006 Pages: 182 PDF File Size: 17.97 Mb ePub File Size: 2.90 Mb ISBN: 782-6-79026-486-2 Downloads: 72048 Price: Free* [*Free Regsitration Required] Uploader: Samulmaran

The Bresenham Algorithm for drawing lines on the discrete plane, such as computer monitor is one of the fundamental algorithms in computer graphics. This algorithm provides the means for the fast and efficient way to represent continuous abstract lines onto discrete plane of computer display.

This process is called rasterization. The algorithm basically approximates real valued line by calculating what pixels to illuminate and to provide “illusion” of line. Since the pixels are sufficiently small, the approximation is good enough to “trick” the human eyes and to get illusion of a real line.

The basic idea is shown on Figure 1 and Figure 2. Figure 1 shows the real line drawn algroithm the pixel grid. The Figure 2 shows how is the same line approximated by “illuminating” particular pixels. Given two endpoints Ax, Ay and Bx, Bywe can chose the start point x ky k.

## Bresenham’s line algorithm

The choice is purely arbitrary, it can be either of Ax,Ay and Bx,By points. From this start point or pixel, we have eight possible choices for the next pixel in the line, since each pixel is surrounded by 8 other pixels except border pixels.

We need to isolate these eight choices into only two choices. These pixels represent the one just to the right and the one to the right and one up pixel, respectively. Below is complete derivation which incorporates all optimization and speed drawung of the algorithm code.

KIBLER SCAPULAR DYSKINESIS PDF

To find the best “next pixel”, first we must find the distances to the two available choices from the ideal location of the real line.

Distance between pixel-to-right and ideal pixel is: So we can simply choose subsequent pixels based on the following: Instead of comparing the two values to each other, we can simply evaluate d1-d2 and test the sign to determine which to choose. If d1-d2 is negative or zero, we will choose pixel-to-right. In addition to this optimization, Bresenham Algorithm suggests draeing optimize more.

If we evaluate d1-d2 as follows: If we now evaluate a new decision variable P kwe get: Since line entity is linear in algoritum nature, P k change will be linear as altorithm, therefore we can evaluate subsequent P k values incrementally by finding a constant change in P k for each subsequent pixel. The summary of the basic steps of the algorithm for “First Octant” is following: Calculate and store absolute value of changes in x and y between endpoints Calculate and Store initial decision value P 0 Calculate and Algorithj decision value increments; one for choosing pixel-to-right and one for choosing pixel-to-right-and-up Setup loop that will process all points stepping in x from Ax to Bx as follows: Draw the derivxtion at the starting point Check decision variable: The basic idea of the Bresenham Algorithm is shown is the previous sectionbut the algorithm can be easily extended to all other lines, not just the lines with slope between 0 and 1.

## derivation of bresenham line algorithm

One subset of the cases is concerned with lines with slope from -1 to 1. In the erawing derivation when we checked the decision variable, we always incremented x and y by positive one.

AVERROES DECISIVE TREATISE PDF

The dX and dY values are always positive regardless of which line is chosen with slope from -1 to 1.

If we keep the start point as point Ax, Aywe can determine the sign of the values to increment. In essence, this proposed solution only changes increments for x and y, decision variable is still the same. The general solution of the Bresenham Algorithm must check for the slope of the line, is it within our previous bounds where x is independent variable deruvation is it where y is independent variable. With slopes greater than 1 or less than -1, we must take the previous implementation and swap all x and y values to “move” the calculations back into the “First Octant”.

For the general solution, this includes swapping dX and dY values, as deruvation. In general, the Bresenham Algorithm, have no floating point numbers, no divisions and it can be implemented using bit shifting as multiplying operation.

This is what this algorithm makes so efficient and fast. Demo implementation of the Bresenham Algorithm implements algorithm for the lines in all directions.

### Computer Science Study Material: Derivation of BRESENHAM’S Line Drawing Algorithm

It shows a screen-like pixel grid and a few cerivation of lines drawn using the Bresenham Algorithm. After the demo is executed in a Ghostscript, user is able to manually enter any two endpoints of the line in order to view the required line drawing. In producing this project web page the following tools are used: On-Line Computer Graphics Notes: