SlideShare a Scribd company logo
Computer Graphics
1 of 5
Lesson 2: Bresenham Line Drawing Algorithm
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 2020 June 19
The screen of a computer is a rectangular grid. A cell in the grid is
called a “pixel”. An example is given below that has 20 × 20 pixels.
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Computer Graphics
2 of 5
Bresenham Line Drawing Algorithm in Step Form for |m| < 1
Note: Let (x1, y1) is the left endpoint, (x2, y2) is the right endpoint,
and m is the gradient of the line segment.
1) Set k = 0.
2) Fill pixel (x[k], y[k]); i.e., fill pixel (x1, y1).
3) Compute p [k] = 2 * dy – dx where dx = x2 – x1 and dy = y2 – y1.
4) If p [k] < 0, fill pixel (x [k] + 1, y [k]) and p [k + 1] = p [k] + 2 * dy.
Otherwise, fill pixel (x [k] + 1, y [k] + 1) and p [k + 1] = p [k] + 2 *
dy – 2 * dx.
5) Set k = k + 1 and go to step 4 if k < dx.
Computer Graphics
3 of 5
Example
Demonstrate drawing a line segment from (2, 3) to (7, 5).
Answer:
5
4
3
2 3 4 5 6 7
k = 0;
SET_PIXEL (2, 3);
5
4
3
2 3 4 5 6 7
dx = 7 – 2 = 5;
dy = 5 – 3 = 2;
p [0] = 2 * 2 – 5 = -1;
p [0] < 0;
SET_PIXEL (3, 3);
5
4
3
2 3 4 5 6 7
Computer Graphics
4 of 5
p [1] = -1 + 2 (2) = 3;
k = 1 < 5;
p [1] ≥ 0;
SET_PIXEL (4, 4);
5
4
3
2 3 4 5 6 7
p [2] = 3 + 2 (2) – 2 (5) = -3;
k = 2 < 5;
p [2] < 0;
SET_PIXEL (5, 4);
5
4
3
2 3 4 5 6 7
p [3] = -3 + 2 (2) = 1;
k = 3 < 5;
Computer Graphics
5 of 5
p [3] ≥ 0;
SET_PIXEL (6, 5);
5
4
3
2 3 4 5 6 7
p [4] = 1 + 2 (2) – 2 (5) = -5;
k = 4 < 5;
p [4] < 0;
SET_PIXEL (7, 5);
5
4
3
2 3 4 5 6 7
p [5] = -5 + 2 (2) = -1;
k = 5 ≥ 5.

More Related Content

What's hot

Computing a square root product
Computing a square root productComputing a square root product
Computing a square root productTutorMate33
 
Lesson 5.3 honors
Lesson 5.3 honorsLesson 5.3 honors
Lesson 5.3 honorsmorrobea
 
University of phoennix mth 209 discussions
University of phoennix mth 209  discussionsUniversity of phoennix mth 209  discussions
University of phoennix mth 209 discussions
leesa marteen
 
Bingo 1 precal
Bingo 1 precalBingo 1 precal
Bingo 1 precal
ezeash17
 
Combined operation
Combined operationCombined operation
Combined operation
culturalcomputingindia
 
Vedic Mathematics- Combined operation Sum and Product of Numbers
Vedic Mathematics- Combined operation Sum and Product of NumbersVedic Mathematics- Combined operation Sum and Product of Numbers
Vedic Mathematics- Combined operation Sum and Product of Numbers
culturalcomputingindia
 
Distance book title
Distance  book titleDistance  book title
Distance book title
Nadeem Uddin
 
IIR filter realization using direct form I & II
IIR filter realization using direct form I & IIIIR filter realization using direct form I & II
IIR filter realization using direct form I & II
Sarang Joshi
 
Bingo 1 precal
Bingo 1 precalBingo 1 precal
Bingo 1 precal
ezeash17
 
Bingo 1 precal
Bingo 1 precalBingo 1 precal
Bingo 1 precal
ezeash17
 
Colour in Mathematics
Colour in Mathematics Colour in Mathematics
Colour in Mathematics
Colleen Young
 
Mb 106 quantitative techniques 7
Mb 106 quantitative techniques 7Mb 106 quantitative techniques 7
Mb 106 quantitative techniques 7
KrishnaRoy45
 
Mb 106 quantitative techniques 4
Mb 106 quantitative techniques 4Mb 106 quantitative techniques 4
Mb 106 quantitative techniques 4
KrishnaRoy45
 
Inequalities day 1 worked
Inequalities day 1 workedInequalities day 1 worked
Inequalities day 1 worked
Jonna Ramsey
 
Structures for FIR systems
Structures for FIR systemsStructures for FIR systems
Structures for FIR systems
Chandan Taluja
 
Multiplying polynomials
Multiplying polynomialsMultiplying polynomials
Multiplying polynomials
QueenPinky644
 
Inequalities day 2 worked
Inequalities day 2 workedInequalities day 2 worked
Inequalities day 2 worked
Jonna Ramsey
 

What's hot (20)

Computing a square root product
Computing a square root productComputing a square root product
Computing a square root product
 
Lesson 5.3 honors
Lesson 5.3 honorsLesson 5.3 honors
Lesson 5.3 honors
 
University of phoennix mth 209 discussions
University of phoennix mth 209  discussionsUniversity of phoennix mth 209  discussions
University of phoennix mth 209 discussions
 
Bingo 1 precal
Bingo 1 precalBingo 1 precal
Bingo 1 precal
 
Combined operation
Combined operationCombined operation
Combined operation
 
Vedic Mathematics- Combined operation Sum and Product of Numbers
Vedic Mathematics- Combined operation Sum and Product of NumbersVedic Mathematics- Combined operation Sum and Product of Numbers
Vedic Mathematics- Combined operation Sum and Product of Numbers
 
Distance book title
Distance  book titleDistance  book title
Distance book title
 
Chptr 1 review
Chptr 1 reviewChptr 1 review
Chptr 1 review
 
IIR filter realization using direct form I & II
IIR filter realization using direct form I & IIIIR filter realization using direct form I & II
IIR filter realization using direct form I & II
 
Bingo 1 precal
Bingo 1 precalBingo 1 precal
Bingo 1 precal
 
Bingo 1 precal
Bingo 1 precalBingo 1 precal
Bingo 1 precal
 
Colour in Mathematics
Colour in Mathematics Colour in Mathematics
Colour in Mathematics
 
Math is fun!
Math is fun!Math is fun!
Math is fun!
 
Mb 106 quantitative techniques 7
Mb 106 quantitative techniques 7Mb 106 quantitative techniques 7
Mb 106 quantitative techniques 7
 
Mb 106 quantitative techniques 4
Mb 106 quantitative techniques 4Mb 106 quantitative techniques 4
Mb 106 quantitative techniques 4
 
Inequalities day 1 worked
Inequalities day 1 workedInequalities day 1 worked
Inequalities day 1 worked
 
Structures for FIR systems
Structures for FIR systemsStructures for FIR systems
Structures for FIR systems
 
karnaugh maps
karnaugh mapskarnaugh maps
karnaugh maps
 
Multiplying polynomials
Multiplying polynomialsMultiplying polynomials
Multiplying polynomials
 
Inequalities day 2 worked
Inequalities day 2 workedInequalities day 2 worked
Inequalities day 2 worked
 

Similar to Bresenham Line Drawing Algorithm

Algebra ii honors study guide
Algebra ii honors study guideAlgebra ii honors study guide
Algebra ii honors study guidemorrobea
 
Algebra ii honors study guide
Algebra ii honors study guideAlgebra ii honors study guide
Algebra ii honors study guidemorrobea
 
Set 1 mawar
Set 1 mawarSet 1 mawar
Set 1 mawar
faazafauzana
 
College algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualCollege algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manual
Annuzzi19
 
lecture 1.pptx
lecture 1.pptxlecture 1.pptx
lecture 1.pptx
MDRAKIB180107
 
Chapter_3_Gate-Level_Minimization.ppt
Chapter_3_Gate-Level_Minimization.pptChapter_3_Gate-Level_Minimization.ppt
Chapter_3_Gate-Level_Minimization.ppt
MdTahsinAmin2
 
35182797 additional-mathematics-form-4-and-5-notes
35182797 additional-mathematics-form-4-and-5-notes35182797 additional-mathematics-form-4-and-5-notes
35182797 additional-mathematics-form-4-and-5-notesWendy Pindah
 
Who wants to pass this course
Who wants to pass this courseWho wants to pass this course
Who wants to pass this course
advancedfunctions
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
Prabin Gautam
 
EPCA_MODULE-2.pptx
EPCA_MODULE-2.pptxEPCA_MODULE-2.pptx
EPCA_MODULE-2.pptx
BenCorejadoAgarcio
 
12 cbse-maths-2014-solution set 1
12 cbse-maths-2014-solution set 1 12 cbse-maths-2014-solution set 1
12 cbse-maths-2014-solution set 1
vandna123
 
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
Jhonatan Minchán
 
Solucionario de matemáticas para administación y economia
Solucionario de matemáticas para administación y economiaSolucionario de matemáticas para administación y economia
Solucionario de matemáticas para administación y economia
Luis Perez Anampa
 
31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual
Mahrukh Khalid
 
Sol mat haeussler_by_priale
Sol mat haeussler_by_prialeSol mat haeussler_by_priale
Sol mat haeussler_by_priale
Jeff Chasi
 
Negative numbers
Negative numbersNegative numbers
Negative numbers
Ahmed Shaaban
 
Non Deterministic and Deterministic Problems
Non Deterministic and Deterministic Problems Non Deterministic and Deterministic Problems
Non Deterministic and Deterministic Problems
Scandala Tamang
 
1 fichas refuerzo operaciones combinadas numeros
1 fichas refuerzo operaciones combinadas numeros1 fichas refuerzo operaciones combinadas numeros
1 fichas refuerzo operaciones combinadas numeros
Bea Marfer
 

Similar to Bresenham Line Drawing Algorithm (20)

Algebra ii honors study guide
Algebra ii honors study guideAlgebra ii honors study guide
Algebra ii honors study guide
 
Algebra ii honors study guide
Algebra ii honors study guideAlgebra ii honors study guide
Algebra ii honors study guide
 
Set 1 mawar
Set 1 mawarSet 1 mawar
Set 1 mawar
 
College algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualCollege algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manual
 
lecture 1.pptx
lecture 1.pptxlecture 1.pptx
lecture 1.pptx
 
Chapter_3_Gate-Level_Minimization.ppt
Chapter_3_Gate-Level_Minimization.pptChapter_3_Gate-Level_Minimization.ppt
Chapter_3_Gate-Level_Minimization.ppt
 
35182797 additional-mathematics-form-4-and-5-notes
35182797 additional-mathematics-form-4-and-5-notes35182797 additional-mathematics-form-4-and-5-notes
35182797 additional-mathematics-form-4-and-5-notes
 
Who wants to pass this course
Who wants to pass this courseWho wants to pass this course
Who wants to pass this course
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
EPCA_MODULE-2.pptx
EPCA_MODULE-2.pptxEPCA_MODULE-2.pptx
EPCA_MODULE-2.pptx
 
12 cbse-maths-2014-solution set 1
12 cbse-maths-2014-solution set 1 12 cbse-maths-2014-solution set 1
12 cbse-maths-2014-solution set 1
 
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
Ernest f. haeussler, richard s. paul y richard j. wood. matemáticas para admi...
 
Solucionario de matemáticas para administación y economia
Solucionario de matemáticas para administación y economiaSolucionario de matemáticas para administación y economia
Solucionario de matemáticas para administación y economia
 
31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual
 
Sol mat haeussler_by_priale
Sol mat haeussler_by_prialeSol mat haeussler_by_priale
Sol mat haeussler_by_priale
 
Negative numbers
Negative numbersNegative numbers
Negative numbers
 
Non Deterministic and Deterministic Problems
Non Deterministic and Deterministic Problems Non Deterministic and Deterministic Problems
Non Deterministic and Deterministic Problems
 
Skills In Add Maths
Skills In Add MathsSkills In Add Maths
Skills In Add Maths
 
Indices
IndicesIndices
Indices
 
1 fichas refuerzo operaciones combinadas numeros
1 fichas refuerzo operaciones combinadas numeros1 fichas refuerzo operaciones combinadas numeros
1 fichas refuerzo operaciones combinadas numeros
 

More from Kasun Ranga Wijeweera

Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
Kasun Ranga Wijeweera
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
Kasun Ranga Wijeweera
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
Kasun Ranga Wijeweera
 
Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a Polygon
Kasun Ranga Wijeweera
 
Geometric Transformations II
Geometric Transformations IIGeometric Transformations II
Geometric Transformations II
Kasun Ranga Wijeweera
 
Geometric Transformations I
Geometric Transformations IGeometric Transformations I
Geometric Transformations I
Kasun Ranga Wijeweera
 
Introduction to Polygons
Introduction to PolygonsIntroduction to Polygons
Introduction to Polygons
Kasun Ranga Wijeweera
 
Loops in Visual Basic: Exercises
Loops in Visual Basic: ExercisesLoops in Visual Basic: Exercises
Loops in Visual Basic: Exercises
Kasun Ranga Wijeweera
 
Conditional Logic: Exercises
Conditional Logic: ExercisesConditional Logic: Exercises
Conditional Logic: Exercises
Kasun Ranga Wijeweera
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic Programming
Kasun Ranga Wijeweera
 
CheckBoxes and RadioButtons
CheckBoxes and RadioButtonsCheckBoxes and RadioButtons
CheckBoxes and RadioButtons
Kasun Ranga Wijeweera
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic Programming
Kasun Ranga Wijeweera
 
Loops in Visual Basic Programming
Loops in Visual Basic ProgrammingLoops in Visual Basic Programming
Loops in Visual Basic Programming
Kasun Ranga Wijeweera
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic Programming
Kasun Ranga Wijeweera
 
Assignment for Variables
Assignment for VariablesAssignment for Variables
Assignment for Variables
Kasun Ranga Wijeweera
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Kasun Ranga Wijeweera
 
Assignment for Events
Assignment for EventsAssignment for Events
Assignment for Events
Kasun Ranga Wijeweera
 
Mastering Arrays Assignment
Mastering Arrays AssignmentMastering Arrays Assignment
Mastering Arrays Assignment
Kasun Ranga Wijeweera
 
Arrays in Visual Basic Programming
Arrays in Visual Basic ProgrammingArrays in Visual Basic Programming
Arrays in Visual Basic Programming
Kasun Ranga Wijeweera
 
An Exercise for Factory Method Design Pattern in C#
An Exercise for Factory Method Design Pattern in C#An Exercise for Factory Method Design Pattern in C#
An Exercise for Factory Method Design Pattern in C#
Kasun Ranga Wijeweera
 

More from Kasun Ranga Wijeweera (20)

Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a Polygon
 
Geometric Transformations II
Geometric Transformations IIGeometric Transformations II
Geometric Transformations II
 
Geometric Transformations I
Geometric Transformations IGeometric Transformations I
Geometric Transformations I
 
Introduction to Polygons
Introduction to PolygonsIntroduction to Polygons
Introduction to Polygons
 
Loops in Visual Basic: Exercises
Loops in Visual Basic: ExercisesLoops in Visual Basic: Exercises
Loops in Visual Basic: Exercises
 
Conditional Logic: Exercises
Conditional Logic: ExercisesConditional Logic: Exercises
Conditional Logic: Exercises
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic Programming
 
CheckBoxes and RadioButtons
CheckBoxes and RadioButtonsCheckBoxes and RadioButtons
CheckBoxes and RadioButtons
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic Programming
 
Loops in Visual Basic Programming
Loops in Visual Basic ProgrammingLoops in Visual Basic Programming
Loops in Visual Basic Programming
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic Programming
 
Assignment for Variables
Assignment for VariablesAssignment for Variables
Assignment for Variables
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]
 
Assignment for Events
Assignment for EventsAssignment for Events
Assignment for Events
 
Mastering Arrays Assignment
Mastering Arrays AssignmentMastering Arrays Assignment
Mastering Arrays Assignment
 
Arrays in Visual Basic Programming
Arrays in Visual Basic ProgrammingArrays in Visual Basic Programming
Arrays in Visual Basic Programming
 
An Exercise for Factory Method Design Pattern in C#
An Exercise for Factory Method Design Pattern in C#An Exercise for Factory Method Design Pattern in C#
An Exercise for Factory Method Design Pattern in C#
 

Recently uploaded

top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
ayushiqss
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 

Recently uploaded (20)

top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 

Bresenham Line Drawing Algorithm

  • 1. Computer Graphics 1 of 5 Lesson 2: Bresenham Line Drawing Algorithm Author: Kasun Ranga Wijeweera Email: krw19870829@gmail.com Date: 2020 June 19 The screen of a computer is a rectangular grid. A cell in the grid is called a “pixel”. An example is given below that has 20 × 20 pixels. 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  • 2. Computer Graphics 2 of 5 Bresenham Line Drawing Algorithm in Step Form for |m| < 1 Note: Let (x1, y1) is the left endpoint, (x2, y2) is the right endpoint, and m is the gradient of the line segment. 1) Set k = 0. 2) Fill pixel (x[k], y[k]); i.e., fill pixel (x1, y1). 3) Compute p [k] = 2 * dy – dx where dx = x2 – x1 and dy = y2 – y1. 4) If p [k] < 0, fill pixel (x [k] + 1, y [k]) and p [k + 1] = p [k] + 2 * dy. Otherwise, fill pixel (x [k] + 1, y [k] + 1) and p [k + 1] = p [k] + 2 * dy – 2 * dx. 5) Set k = k + 1 and go to step 4 if k < dx.
  • 3. Computer Graphics 3 of 5 Example Demonstrate drawing a line segment from (2, 3) to (7, 5). Answer: 5 4 3 2 3 4 5 6 7 k = 0; SET_PIXEL (2, 3); 5 4 3 2 3 4 5 6 7 dx = 7 – 2 = 5; dy = 5 – 3 = 2; p [0] = 2 * 2 – 5 = -1; p [0] < 0; SET_PIXEL (3, 3); 5 4 3 2 3 4 5 6 7
  • 4. Computer Graphics 4 of 5 p [1] = -1 + 2 (2) = 3; k = 1 < 5; p [1] ≥ 0; SET_PIXEL (4, 4); 5 4 3 2 3 4 5 6 7 p [2] = 3 + 2 (2) – 2 (5) = -3; k = 2 < 5; p [2] < 0; SET_PIXEL (5, 4); 5 4 3 2 3 4 5 6 7 p [3] = -3 + 2 (2) = 1; k = 3 < 5;
  • 5. Computer Graphics 5 of 5 p [3] ≥ 0; SET_PIXEL (6, 5); 5 4 3 2 3 4 5 6 7 p [4] = 1 + 2 (2) – 2 (5) = -5; k = 4 < 5; p [4] < 0; SET_PIXEL (7, 5); 5 4 3 2 3 4 5 6 7 p [5] = -5 + 2 (2) = -1; k = 5 ≥ 5.