The document discusses Bresenham's line drawing algorithm. It describes how the algorithm uses integer calculations to determine which pixel to plot when drawing a line between two points. It works by incrementing along the x-axis and choosing between two possible y-coordinates at each step based on their distance to the true line. The algorithm is derived step-by-step and an example is provided to illustrate its use.
The document discusses computer graphics output primitives and line drawing algorithms. It describes points, lines, polygons and other basic geometric structures used to describe scenes in graphics. It then explains two common line drawing algorithms - the Digital Differential Analyzer (DDA) algorithm and Bresenham's line drawing algorithm. Bresenham's algorithm uses only integer calculations to efficiently rasterize lines and is often used in computer graphics.
Bresenham's line algorithm is an efficient method for drawing lines on a digital display. It works by calculating the next pixel coordinate along the line using integer math only. This avoids complex floating point calculations. It starts at the initial coordinate and iteratively calculates the next x,y coordinate using integer addition and comparisons until it reaches the final endpoint.
The document discusses computer graphics concepts like points, pixels, lines, and circles. It begins with definitions of pixels and how they relate to points in geometry. It then covers the basic structure for specifying points in OpenGL and how to draw points, lines, and triangles. Next, it discusses algorithms for drawing lines, including the digital differential analyzer (DDA) method and Bresenham's line algorithm. Finally, it covers circle drawing and introduces the mid-point circle algorithm. In summary:
1) It defines key computer graphics concepts like pixels, points, lines, and circles.
2) It explains the basic OpenGL functions for drawing points and lines and provides examples of drawing simple shapes.
3) It
OpenGL (Open Graphics Library) is a cross-platform, hardware-accelerated, language-independent, industrial standard API for producing 3D (including 2D) graphics. Modern computers have dedicated GPU (Graphics Processing Unit) with its own memory to speed up graphics rendering.
Bresenham's line algorithm uses incremental integer calculations to determine which pixels to turn on when drawing a line on a pixel-based display. It works by calculating a decision parameter Pk at each step k to determine whether to plot the pixel at (Xk+1,Yk) or (Xk+1,Yk+1). For a given line from (30,20) to (40,28), the algorithm is applied by initializing P0=6 and then iteratively calculating Pk+1 at each step k by adding either 2dy or 2dy-2dx depending on whether Pk is positive or negative. This tracks the line from (30,20) to (40,28)
The document discusses three algorithms for line generation in computer graphics:
1. The DDA algorithm calculates increments in x and y coordinates between two endpoints and plots pixels along the line incrementally.
2. Bresenham's algorithm uses integer calculations and chooses pixel coordinates closest to the true line by comparing differences above and below the line.
3. The mid-point algorithm calculates the midpoint between potential next points and chooses the one closest to the true line based on whether the intersection is above or below the midpoint.
The document summarizes Bresenham's line drawing algorithm. It derives the equations for calculating the next pixel position when drawing a line on a digital display. It considers cases where the slope is less than or equal to 1 and greater than 1. For each case, it calculates the distance from intersection points to pixel positions and derives the decision parameter equation to determine the next pixel.
The document derives Bresenham's line algorithm for drawing lines on a discrete grid. It starts with the line equation and defines variables for the slope and intercept. It then calculates the distance d1 and d2 from the line to two possible pixel locations and expresses their difference in terms of the slope and intercept. By multiplying this difference by the change in x, it removes the floating point slope value, resulting in an integer comparison expression. This is defined recursively to draw each subsequent pixel, using pre-computed constants. The initial p0 value is also derived from the line endpoint coordinates.
The document derives Bresenham's line algorithm for drawing lines on a discrete grid. It starts with the line equation and defines variables for the slope and intercept. It then calculates the distance d1 and d2 from the line to two possible pixel locations and shows that the sign of d1-d2 determines which pixel to plot. The derivation continues by multiplying d1-d2 by the change in x to obtain an integer parameter pi, which is then defined recursively to form the core of the algorithm using only integer calculations. Initial and increment values for pi are also derived. Finally, pseudocode is provided to outline the complete algorithm.
Bresenhems line Genration derivation for Mtechrahulkatre9
This document describes Bresenham's line algorithm for drawing lines on a pixel-based display. It discusses how Bresenham's algorithm uses integer arithmetic to calculate pixel coordinates along the line between two points, to avoid issues with floating-point values. The algorithm works by incrementing the x coordinate by 1 each time and selectively increasing the y coordinate to stay closest to the true line. It uses a decision parameter and slope error value to determine whether to increment y at each step. Examples are provided to illustrate the output coordinates generated between two points.
The document describes algorithms for scan converting primitive geometric objects like lines, circles, and ellipses. It explains Bresenham's line algorithm which uses integer arithmetic to efficiently determine the pixel locations along a line path, getting closer to the actual line than the traditional Digital Differential Analyzer (DDA) algorithm. It also covers the midpoint circle algorithm which uses distance comparison to test the midpoint between pixels to decide if it is inside or outside the circle boundary during scan conversion.
The document discusses scan conversion, which is the last step in the graphics pipeline that efficiently draws primitive graphics like lines and polygons to a 2D raster. It describes Bresenham's algorithm, a widely-used incremental algorithm for drawing lines on a raster display. The algorithm uses only integer arithmetic to compute the pixel coordinates along the line without rounding errors. It works by choosing between the two possible next pixels at each step based on the sign of a decision variable, and efficiently updating this variable to traverse the line.
Jack Bresenham developed an efficient algorithm for drawing lines on a raster display. The Bresenham's line algorithm uses only integer arithmetic to determine the next pixel to plot, allowing fast computation. It works by calculating a decision parameter to choose either the upper or lower pixel as it moves from the starting to ending point of the line. The algorithm guarantees connected lines and plots each point exactly once for accurate rendering compared to other methods.
The document discusses algorithms for drawing lines and circles on a discrete pixel display. It begins by describing what characteristics an "ideal line" would have on such a display. It then introduces several algorithms for drawing lines, including the simple line algorithm, digital differential analyzer (DDA) algorithm, and Bresenham's line algorithm. The Bresenham algorithm is described in detail, as it uses only integer calculations. Next, a simple potential circle drawing algorithm is presented and its shortcomings discussed. Finally, the more accurate and efficient mid-point circle algorithm is described. This algorithm exploits the eight-way symmetry of circles and uses incremental calculations to determine the next pixel point.
The document discusses algorithms for drawing lines and circles on a discrete pixel display. It begins by describing what characteristics an "ideal line" would have on such a display. It then introduces several algorithms for drawing lines, including the simple line algorithm, digital differential analyzer (DDA) algorithm, and Bresenham's line algorithm. The Bresenham algorithm is described in detail, as it uses only integer calculations. Next, a simple potential circle drawing algorithm is presented and its shortcomings discussed. Finally, the more accurate and efficient mid-point circle algorithm is introduced. This algorithm exploits the eight-way symmetry of circles and only calculates points in one octant.
This document discusses several algorithms for drawing lines in computer graphics, including their requirements, properties, and steps. It describes the digital differential analyzer (DDA) algorithm, which uses incremental differences between line endpoints to plot pixels along the line. Bresenham's line algorithm is also summarized, which uses integer calculations to determine pixel positions with good visual quality. A parallel line algorithm is mentioned that can partition line drawing computations across multiple processors to calculate pixel positions efficiently in parallel.
This document discusses several algorithms for drawing lines in computer graphics, including their requirements, properties, and steps. It describes the digital differential analyzer (DDA) algorithm, which uses incremental differences between line endpoints to plot pixels along the line. Bresenham's line algorithm is also summarized, which uses integer calculations to determine pixel positions with good visual quality. A parallel line algorithm is mentioned that can partition line drawing computations across multiple processors to calculate pixel positions efficiently in parallel.
The document discusses algorithms for drawing lines in computer graphics. It describes the Digital Differential Analyzer (DDA) algorithm, which uses incremental calculations at each step to determine the next (x,y) coordinate on the line. It then explains the Bresenham line algorithm, which only uses integer calculations to determine the next coordinate, avoiding issues with rounding errors that can occur with DDA. The Bresenham algorithm calculates an initial decision parameter and uses this to efficiently determine whether the next point is above or below the line at each increment of the x or y-value, depending on the slope.
Commonly a fixed area of the system memory is reserved for the frame buffer,
Video controller can direct access to the frame-buffer
Frame-buffer locations, and the corresponding screen positions, are referenced in Cartesian coordinates.
Some system employ lower-left corner as origin
But most common system employ upper-left corner as origin.
Scan lines are labeled from ymax, at the top of the screen to 0 at the bottom.
Along each scan line, screen pixel positions are labeled from 0 to xmax
Bresenham line-drawing-algorithm By S L Sonawane.pdfSujataSonawane11
This document provides an overview of Bresenham's line algorithm, which is an efficient method for drawing straight lines on a raster display. It uses only integer arithmetic like addition, subtraction, and multiplication by 2, which computers can perform quickly. The algorithm works by selecting the optimal raster points to represent a line by incrementing either the x or y coordinate by one unit at each step, depending on the slope of the line. It determines which coordinate to increment by examining the distance between the actual line and the nearest pixel, called the decision parameter. While fast and accurate, lines drawn with this algorithm may not be perfectly smooth. Examples are provided to illustrate applying the algorithm to draw several lines.
It gives detailed description about Points, Lines, Attributes of Output Primitives, Line Functions, Line Drawing Algorithms, DDA Line drawing algorithms, Bresenham’s Line Algorithm, Circle Generating Algorthims
Computer graphics - bresenham line drawing algorithmRuchi Maurya
You know that DDA algorithm is an incremental scan conversion method which performs calculations at each step using the results from the preceding step. Here we are going to discover an accurate and efficient raster line generating algorithm, the Bresenham's line-drawing algorithm.
This algorithm was developed by Jack E. Bresenham in 1962 at IBM.
The function given below handles all lines and implements the complete Bresenham's algorithm.
function line(x0, x1, y0, y1)
boolean steep := abs(y1 - y0) > abs(x1 - x0)
if steep then
swap(x0, y0)
swap(x1, y1)
if x0 > x1 then
swap(x0, x1)
swap(y0, y1)
int deltax := x1 - x0
int deltay := abs(y1 - y0)
real error := 0
real deltaerr := deltay / deltax
int y := y0
if y0 < y1 then ystep := 1 else ystep := -1
for x from x0 to x1
if steep then plot(y,x) else plot(x,y)
error := error + deltaerr
if error ? 0.5
y := y + ystep
error := error - 1.0
The document discusses several common algorithms for computer graphics rendering including Bresenham's line drawing algorithm, the midpoint circle algorithm, and scanline polygon filling. Bresenham's algorithm uses only integer calculations to efficiently draw lines. The midpoint circle algorithm incrementally chooses pixel coordinates to draw circles with eightfold symmetry and without floating point operations. Scanline polygon filling finds the edge intersections on each scanline and fills pixels between interior intersections.
The document derives Bresenham's line algorithm for drawing lines on a discrete grid. It starts with the line equation and defines variables for the slope and intercept. It then calculates the distance d1 and d2 from the line to two possible pixel locations and expresses their difference in terms of the slope and intercept. By multiplying this difference by the change in x, it removes the floating point slope value, resulting in an integer comparison expression. This is defined recursively to draw each subsequent pixel, using pre-computed constants. The initial p0 value is also derived from the line endpoint coordinates.
The document derives Bresenham's line algorithm for drawing lines on a discrete grid. It starts with the line equation and defines variables for the slope and intercept. It then calculates the distance d1 and d2 from the line to two possible pixel locations and shows that the sign of d1-d2 determines which pixel to plot. The derivation continues by multiplying d1-d2 by the change in x to obtain an integer parameter pi, which is then defined recursively to form the core of the algorithm using only integer calculations. Initial and increment values for pi are also derived. Finally, pseudocode is provided to outline the complete algorithm.
Bresenhems line Genration derivation for Mtechrahulkatre9
This document describes Bresenham's line algorithm for drawing lines on a pixel-based display. It discusses how Bresenham's algorithm uses integer arithmetic to calculate pixel coordinates along the line between two points, to avoid issues with floating-point values. The algorithm works by incrementing the x coordinate by 1 each time and selectively increasing the y coordinate to stay closest to the true line. It uses a decision parameter and slope error value to determine whether to increment y at each step. Examples are provided to illustrate the output coordinates generated between two points.
The document describes algorithms for scan converting primitive geometric objects like lines, circles, and ellipses. It explains Bresenham's line algorithm which uses integer arithmetic to efficiently determine the pixel locations along a line path, getting closer to the actual line than the traditional Digital Differential Analyzer (DDA) algorithm. It also covers the midpoint circle algorithm which uses distance comparison to test the midpoint between pixels to decide if it is inside or outside the circle boundary during scan conversion.
The document discusses scan conversion, which is the last step in the graphics pipeline that efficiently draws primitive graphics like lines and polygons to a 2D raster. It describes Bresenham's algorithm, a widely-used incremental algorithm for drawing lines on a raster display. The algorithm uses only integer arithmetic to compute the pixel coordinates along the line without rounding errors. It works by choosing between the two possible next pixels at each step based on the sign of a decision variable, and efficiently updating this variable to traverse the line.
Jack Bresenham developed an efficient algorithm for drawing lines on a raster display. The Bresenham's line algorithm uses only integer arithmetic to determine the next pixel to plot, allowing fast computation. It works by calculating a decision parameter to choose either the upper or lower pixel as it moves from the starting to ending point of the line. The algorithm guarantees connected lines and plots each point exactly once for accurate rendering compared to other methods.
The document discusses algorithms for drawing lines and circles on a discrete pixel display. It begins by describing what characteristics an "ideal line" would have on such a display. It then introduces several algorithms for drawing lines, including the simple line algorithm, digital differential analyzer (DDA) algorithm, and Bresenham's line algorithm. The Bresenham algorithm is described in detail, as it uses only integer calculations. Next, a simple potential circle drawing algorithm is presented and its shortcomings discussed. Finally, the more accurate and efficient mid-point circle algorithm is described. This algorithm exploits the eight-way symmetry of circles and uses incremental calculations to determine the next pixel point.
The document discusses algorithms for drawing lines and circles on a discrete pixel display. It begins by describing what characteristics an "ideal line" would have on such a display. It then introduces several algorithms for drawing lines, including the simple line algorithm, digital differential analyzer (DDA) algorithm, and Bresenham's line algorithm. The Bresenham algorithm is described in detail, as it uses only integer calculations. Next, a simple potential circle drawing algorithm is presented and its shortcomings discussed. Finally, the more accurate and efficient mid-point circle algorithm is introduced. This algorithm exploits the eight-way symmetry of circles and only calculates points in one octant.
This document discusses several algorithms for drawing lines in computer graphics, including their requirements, properties, and steps. It describes the digital differential analyzer (DDA) algorithm, which uses incremental differences between line endpoints to plot pixels along the line. Bresenham's line algorithm is also summarized, which uses integer calculations to determine pixel positions with good visual quality. A parallel line algorithm is mentioned that can partition line drawing computations across multiple processors to calculate pixel positions efficiently in parallel.
This document discusses several algorithms for drawing lines in computer graphics, including their requirements, properties, and steps. It describes the digital differential analyzer (DDA) algorithm, which uses incremental differences between line endpoints to plot pixels along the line. Bresenham's line algorithm is also summarized, which uses integer calculations to determine pixel positions with good visual quality. A parallel line algorithm is mentioned that can partition line drawing computations across multiple processors to calculate pixel positions efficiently in parallel.
The document discusses algorithms for drawing lines in computer graphics. It describes the Digital Differential Analyzer (DDA) algorithm, which uses incremental calculations at each step to determine the next (x,y) coordinate on the line. It then explains the Bresenham line algorithm, which only uses integer calculations to determine the next coordinate, avoiding issues with rounding errors that can occur with DDA. The Bresenham algorithm calculates an initial decision parameter and uses this to efficiently determine whether the next point is above or below the line at each increment of the x or y-value, depending on the slope.
Commonly a fixed area of the system memory is reserved for the frame buffer,
Video controller can direct access to the frame-buffer
Frame-buffer locations, and the corresponding screen positions, are referenced in Cartesian coordinates.
Some system employ lower-left corner as origin
But most common system employ upper-left corner as origin.
Scan lines are labeled from ymax, at the top of the screen to 0 at the bottom.
Along each scan line, screen pixel positions are labeled from 0 to xmax
Bresenham line-drawing-algorithm By S L Sonawane.pdfSujataSonawane11
This document provides an overview of Bresenham's line algorithm, which is an efficient method for drawing straight lines on a raster display. It uses only integer arithmetic like addition, subtraction, and multiplication by 2, which computers can perform quickly. The algorithm works by selecting the optimal raster points to represent a line by incrementing either the x or y coordinate by one unit at each step, depending on the slope of the line. It determines which coordinate to increment by examining the distance between the actual line and the nearest pixel, called the decision parameter. While fast and accurate, lines drawn with this algorithm may not be perfectly smooth. Examples are provided to illustrate applying the algorithm to draw several lines.
It gives detailed description about Points, Lines, Attributes of Output Primitives, Line Functions, Line Drawing Algorithms, DDA Line drawing algorithms, Bresenham’s Line Algorithm, Circle Generating Algorthims
Computer graphics - bresenham line drawing algorithmRuchi Maurya
You know that DDA algorithm is an incremental scan conversion method which performs calculations at each step using the results from the preceding step. Here we are going to discover an accurate and efficient raster line generating algorithm, the Bresenham's line-drawing algorithm.
This algorithm was developed by Jack E. Bresenham in 1962 at IBM.
The function given below handles all lines and implements the complete Bresenham's algorithm.
function line(x0, x1, y0, y1)
boolean steep := abs(y1 - y0) > abs(x1 - x0)
if steep then
swap(x0, y0)
swap(x1, y1)
if x0 > x1 then
swap(x0, x1)
swap(y0, y1)
int deltax := x1 - x0
int deltay := abs(y1 - y0)
real error := 0
real deltaerr := deltay / deltax
int y := y0
if y0 < y1 then ystep := 1 else ystep := -1
for x from x0 to x1
if steep then plot(y,x) else plot(x,y)
error := error + deltaerr
if error ? 0.5
y := y + ystep
error := error - 1.0
The document discusses several common algorithms for computer graphics rendering including Bresenham's line drawing algorithm, the midpoint circle algorithm, and scanline polygon filling. Bresenham's algorithm uses only integer calculations to efficiently draw lines. The midpoint circle algorithm incrementally chooses pixel coordinates to draw circles with eightfold symmetry and without floating point operations. Scanline polygon filling finds the edge intersections on each scanline and fills pixels between interior intersections.
Better Builder Magazine brings together premium product manufactures and leading builders to create better differentiated homes and buildings that use less energy, save water and reduce our impact on the environment. The magazine is published four times a year.
DIY Gesture Control ESP32 LiteWing Drone using PythonCircuitDigest
Build a gesture-controlled LiteWing drone using ESP32 and MPU6050. This presentation explains components, circuit diagram, assembly steps, and working process.
Read more : https://circuitdigest.com/microcontroller-projects/diy-gesture-controlled-drone-using-esp32-and-python-with-litewing
Ideal for DIY drone projects, robotics enthusiasts, and embedded systems learners. Explore how to create a low-cost, ESP32 drone with real-time wireless gesture control.
Department of Environment (DOE) Mix Design with Fly Ash.MdManikurRahman
Concrete Mix Design with Fly Ash by DOE Method. The Department of Environmental (DOE) approach to fly ash-based concrete mix design is covered in this study.
The Department of Environment (DOE) method of mix design is a British method originally developed in the UK in the 1970s. It is widely used for concrete mix design, including mixes that incorporate supplementary cementitious materials (SCMs) such as fly ash.
When using fly ash in concrete, the DOE method can be adapted to account for its properties and effects on workability, strength, and durability. Here's a step-by-step overview of how the DOE method is applied with fly ash.
THE RISK ASSESSMENT AND TREATMENT APPROACH IN ORDER TO PROVIDE LAN SECURITY B...ijfcstjournal
Local Area Networks(LAN) at present become an important instrument for organizing of process and
information communication in an organization. They provides important purposes such as association of
large amount of data, hardware and software resources and expanding of optimum communications.
Becase these network do work with valuable information, the problem of security providing is an important
issue in organization. So, the stablishment of an information security management system(ISMS) in
organization is significant. In this paper, we introduce ISMS and its implementation in LAN scop. The
assets of LAN and threats and vulnerabilities of these assets are identified, the risks are evaluated and
techniques to reduce them and at result security establishment of the network is expressed.
This presentation provides a detailed overview of air filter testing equipment, including its types, working principles, and industrial applications. Learn about key performance indicators such as filtration efficiency, pressure drop, and particulate holding capacity. The slides highlight standard testing methods (e.g., ISO 16890, EN 1822, ASHRAE 52.2), equipment configurations (such as aerosol generators, particle counters, and test ducts), and the role of automation and data logging in modern systems. Ideal for engineers, quality assurance professionals, and researchers involved in HVAC, automotive, cleanroom, or industrial filtration systems.
2. Index
o The Bresenham algorithm
o Review
o The Big Idea
o Deriving The Bresenham Line Algorithm
o The Bresenham Line Algorithm
o Examples
o Tasks
o Summary
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
2
3. Objective of the today’s topic
• To Understand the basic concept of line drawing
algorithm.
• To Study that how line is draw on raster display.
• To understand a mathematical background of
Bresenham’s line algorithm.
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
3
4. The Bresenham Line Algorithm
• The Bresenham algorithm is
another incremental scan
conversion algorithm
• The big advantage of this algorithm
is that it uses only integer
calculations
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
4
Jack Bresenham worked for 27
years at IBM before entering
academia. Bresenham developed
his famous algorithms at IBM in
t h e e a r l y 1 9 6 0 s
5. Review
• Point Slope Line Equation:
• y = m.x + b
• Slope:
• m = y2 − y1 / x2 − x1 = Δy / Δx
• y-intercept
• b = y1 − m.x1
• x-interval
• Δx = Δy / m
• y-interval
• Δy = m Δx
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
5
6. The Big Idea
• Move across the x axis in unit intervals and at each step
choose between two different y coordinates
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
6
2 3 4 5
2
4
3
5
(xk, yk)
(xk+1, yk)
(xk+1, yk+1)
(Previous)
NE (next)
E (next)
• For example, from
position (2, 3) we have to
choose between (3, 3)
and (3, 4)
• We would like the pixel
that is closer to the
original line
7. Deriving the Bresenham line algorithm
• At sample position xk+1 the vertical separations from
the mathematical line are labelled dupper and dlower
• The y coordinate on the mathematical line at xk+1 is:
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
7
b
x
m
y k +
+
= )
1
(
y
yk
yk+1
xk+1
dlower
dupper
8. Deriving the Bresenham line algorithm (cont…)
• So, dupper and dlower are given as follows:
• and:
• We can use these equations to make a simple decision
about which pixel is closer to the mathematical line.
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
8
k
lower y
y
d −
=
k
k
Lower y
b
x
m
d −
+
+
= )
1
(
y
y
d k
upper −
+
= )
1
(
b
x
m
y k
k −
+
−
+
= )
1
(
1
9. Deriving the Bresenham line algorithm (cont…)
• This simple decision is based on the difference between
the two pixel positions:
• Let’s substitute m with ∆y/∆x where ∆x and ∆y are the
differences between the end-points:
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
9
1
2
2
)
1
(
2 −
+
−
+
=
− b
y
x
m
d
d k
k
upper
lower
)
)
1
(
1
(
)
)
1
(
( b
x
m
y
y
b
x
m
d
d k
k
k
k
Uper
Lower −
+
−
+
−
−
+
+
=
−
)
1
2
2
)
1
(
2
(
)
( −
+
−
+
=
−
b
y
x
x
y
x
d
d
x k
k
upper
lower
)
1
2
(
2
2
2 −
+
+
−
= b
x
y
y
x
x
y k
k
c
y
x
x
y k
k +
−
= 2
2
10. The Bresenham line algorithm
• BRESENHAM’S LINE DRAWING ALGORITHM
(for |m| < 1.0)
1. Input the two line end-points, storing the left end-
point in (x0, y0)
2. Plot the point (x0, y0)
3. Calculate the constants Δx, Δy, 2Δy, and (2Δy - 2Δx)
and get the first value for the decision parameter as:
4. At each xk along the line, starting at k = 0, perform the
following test. If pk < 0, the next point to plot is
(xk+1, yk) and:
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
10
x
y
p
−
= 2
0
y
p
p k
k
+
=
+ 2
1
11. The Bresenham line algorithm
Otherwise, the next point to plot is (xk+1, yk+1) and:
5. Repeat step 4 (Δx – 1) times
• The algorithm and derivation above assumes slopes are
less than 1. for other slopes we need to adjust the
algorithm slightly.
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
11
x
y
p
p k
k
−
+
=
+ 2
2
1
12. Example 1
• Let the given end points for the line be (30,20) and (40, 28)
• M = dy = y2 – y1 = 28 – 20 = 8
• dx x2 – x1 40 – 30 = 10
• m = 0.8
• dy = 8 and dx = 10
• The initial decision parameter P0 is
• P0 = 2dy – dx = 2(8) – 10 = 16 – 10 = 6
• P0 = 6>0, there x and y will be increase with interval one.
• The constants 2dy and 2dy-2dx are
• 2dy = 2(8) = 16 2dy-2dx = 2(8)- 2(10) =16 – 20
• 2dy = 16 2dy – 2dx = - 4
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
12
18. Task 1
• Consider the line from (5, 8) to (9,11),use general
Bresenham’s line algorithm to rasterize this line.
Evaluate and tabulate all the steps involved.
18
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
19. Task 2
• Consider the line from (0, 0) to (-8,-4), use general
Bresenham’s line algorithm to rasterize this line.
Evaluate and tabulate all the steps involved.
19
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
20. Bresenham Line Algorithm Summary
• The Bresenham line algorithm has the following
advantages:
• A fast incremental algorithm
• Uses only integer calculations
• Comparing this to the DDA algorithm, DDA has the
following problems:
• Accumulation of round-off errors can make the pixelated line
drift away from what was intended
• The rounding operations and floating-point arithmetic
involved are time consuming
20
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
21. Assignment No.1
• Explore the Bresenham’s line algorithm procedure
(for |m| >1.0)
Faiz.Ur.Rehman, Lecturer CS-GPGC Kohat
21