SlideShare a Scribd company logo
1 of 5
Download to read offline
Computer Graphics
1 of 5
Lesson 1: Digital Differential Analyzer Line Drawing Algorithm
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 2020 June 16
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
Pseudocode of Digital Differential Analyzer Line Drawing Algorithm
VOID draw (INTEGER x1, INTEGER y1, INTEGER x2, INTEGER y2)
{
INTEGER dx, dy, steps, k;
REAL xInc, yInc, x, y;
dx = x2 – x1;
dy = y2 – y1;
x = x1;
y = y1;
IF (|dx| > |dy|)
steps = |dx|
ELSE
steps = |dy|
END IF
xInc = dx/steps;
yInc = dy/steps;
SET_PIXEL (ROUND (x), ROUND (y));
FOR (k = 1 TO steps)
x = x + xInc;
y = y + yInc;
SET_PIXEL (ROUND (x), ROUND (y));
END FOR
}
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
draw (2, 3, 7, 5);
dx = 7 – 2 = 5;
dy = 5 – 3 = 2;
x = 2;
y = 3;
5 > 2 TRUE;
steps = 5;
xInc = 5/5 = 1;
yInc = 2/5 = 0.4;
SET_PIXEL (2, 3);
5
4
3
2 3 4 5 6 7
Computer Graphics
4 of 5
k = 1
x = 2 + 1 = 3;
y = 3 + 0.4 = 3.4;
SET_PIXEL (3, 3);
5
4
3
2 3 4 5 6 7
k = 2
x = 3 + 1 = 4;
y = 3.4 + 0.4 = 3.8;
SET_PIXEL (4, 4);
5
4
3
2 3 4 5 6 7
k = 3
x = 4 + 1 = 5;
y = 3.8 + 0.4 = 4.2;
SET_PIXEL (5, 4);
5
4
3
2 3 4 5 6 7
Computer Graphics
5 of 5
k = 4
x = 5 + 1 = 6;
y = 4.2 + 0.4 = 4.6;
SET_PIXEL (6, 5);
5
4
3
2 3 4 5 6 7
k = 5
x = 6 + 1 = 7;
y = 4.6 + 0.4 = 5;
SET_PIXEL (7, 5);
5
4
3
2 3 4 5 6 7

More Related Content

What's hot

Mathsquares3
Mathsquares3Mathsquares3
Mathsquares3zeinabze
 
Practica les taules
Practica les taulesPractica les taules
Practica les taulesLaia Lila
 
Perhitungan Variogram, Histogram, Gaussian Model, Isotropic Variogram dan Ani...
Perhitungan Variogram, Histogram, Gaussian Model, Isotropic Variogram dan Ani...Perhitungan Variogram, Histogram, Gaussian Model, Isotropic Variogram dan Ani...
Perhitungan Variogram, Histogram, Gaussian Model, Isotropic Variogram dan Ani...National Cheng Kung University
 
6.07 collaboration
6.07 collaboration6.07 collaboration
6.07 collaborationnherrera16
 
Chapter 5 decision tree induction using frequency tables for attribute selection
Chapter 5 decision tree induction using frequency tables for attribute selectionChapter 5 decision tree induction using frequency tables for attribute selection
Chapter 5 decision tree induction using frequency tables for attribute selectionKy Hong Le
 
Class 9 Cbse Hindi A Sample Paper Term 2 2013
Class 9 Cbse Hindi A Sample Paper Term 2 2013Class 9 Cbse Hindi A Sample Paper Term 2 2013
Class 9 Cbse Hindi A Sample Paper Term 2 2013Sunaina Rawat
 
Multiplying polynomials
Multiplying polynomialsMultiplying polynomials
Multiplying polynomialsQueenPinky644
 
1.4 puzzle time
1.4 puzzle time1.4 puzzle time
1.4 puzzle timemcvannj
 
A2. u1. calculo diferencial. unadm
A2. u1. calculo diferencial. unadmA2. u1. calculo diferencial. unadm
A2. u1. calculo diferencial. unadmLuisa Mee 666
 
Differentiation pdf
Differentiation pdfDifferentiation pdf
Differentiation pdfssuser6cd120
 
Introduction to the trigonometric functions
Introduction to the trigonometric functionsIntroduction to the trigonometric functions
Introduction to the trigonometric functionsGoetheschule
 
1.4 practice
1.4 practice1.4 practice
1.4 practicemcvannj
 
Summer Task -MATHS - Sample s1 questions for 6th form sheet
Summer Task -MATHS - Sample s1 questions for 6th form sheetSummer Task -MATHS - Sample s1 questions for 6th form sheet
Summer Task -MATHS - Sample s1 questions for 6th form sheetWelling School Sixth Form
 
1.3 puzzle time
1.3 puzzle time1.3 puzzle time
1.3 puzzle timemcvannj
 

What's hot (18)

Notes 3-1
Notes 3-1Notes 3-1
Notes 3-1
 
Mathsquares3
Mathsquares3Mathsquares3
Mathsquares3
 
Practica les taules
Practica les taulesPractica les taules
Practica les taules
 
Exam 2 review day 1
Exam 2 review day 1Exam 2 review day 1
Exam 2 review day 1
 
Perhitungan Variogram, Histogram, Gaussian Model, Isotropic Variogram dan Ani...
Perhitungan Variogram, Histogram, Gaussian Model, Isotropic Variogram dan Ani...Perhitungan Variogram, Histogram, Gaussian Model, Isotropic Variogram dan Ani...
Perhitungan Variogram, Histogram, Gaussian Model, Isotropic Variogram dan Ani...
 
6.07 collaboration
6.07 collaboration6.07 collaboration
6.07 collaboration
 
Chapter 5 decision tree induction using frequency tables for attribute selection
Chapter 5 decision tree induction using frequency tables for attribute selectionChapter 5 decision tree induction using frequency tables for attribute selection
Chapter 5 decision tree induction using frequency tables for attribute selection
 
Class 9 Cbse Hindi A Sample Paper Term 2 2013
Class 9 Cbse Hindi A Sample Paper Term 2 2013Class 9 Cbse Hindi A Sample Paper Term 2 2013
Class 9 Cbse Hindi A Sample Paper Term 2 2013
 
Multiplying polynomials
Multiplying polynomialsMultiplying polynomials
Multiplying polynomials
 
1.4 puzzle time
1.4 puzzle time1.4 puzzle time
1.4 puzzle time
 
A2. u1. calculo diferencial. unadm
A2. u1. calculo diferencial. unadmA2. u1. calculo diferencial. unadm
A2. u1. calculo diferencial. unadm
 
C27.2
C27.2C27.2
C27.2
 
Differentiation pdf
Differentiation pdfDifferentiation pdf
Differentiation pdf
 
Introduction to the trigonometric functions
Introduction to the trigonometric functionsIntroduction to the trigonometric functions
Introduction to the trigonometric functions
 
Math
MathMath
Math
 
1.4 practice
1.4 practice1.4 practice
1.4 practice
 
Summer Task -MATHS - Sample s1 questions for 6th form sheet
Summer Task -MATHS - Sample s1 questions for 6th form sheetSummer Task -MATHS - Sample s1 questions for 6th form sheet
Summer Task -MATHS - Sample s1 questions for 6th form sheet
 
1.3 puzzle time
1.3 puzzle time1.3 puzzle time
1.3 puzzle time
 

Similar to Digital Differential Analyzer Line Drawing Algorithm

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
 
Sol mat haeussler_by_priale
Sol mat haeussler_by_prialeSol mat haeussler_by_priale
Sol mat haeussler_by_prialeJeff Chasi
 
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-manualMahrukh Khalid
 
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 economiaLuis Perez Anampa
 
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 manualAnnuzzi19
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptxssuser255bf1
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graphkinan keshkeh
 
20190907 Julia the language for future
20190907 Julia the language for future20190907 Julia the language for future
20190907 Julia the language for future岳華 杜
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programsAbhishek Jena
 
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)Wataru Shito
 
Idea for ineractive programming language
Idea for ineractive programming languageIdea for ineractive programming language
Idea for ineractive programming languageLincoln Hannah
 

Similar to Digital Differential Analyzer Line Drawing Algorithm (20)

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...
 
Sol mat haeussler_by_priale
Sol mat haeussler_by_prialeSol mat haeussler_by_priale
Sol mat haeussler_by_priale
 
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
 
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
 
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
 
C arrays
C arraysC arrays
C arrays
 
Game theory lecture
Game theory   lectureGame theory   lecture
Game theory lecture
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Aditazz 01-ul
Aditazz 01-ulAditazz 01-ul
Aditazz 01-ul
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
MATLAB ARRAYS
MATLAB ARRAYSMATLAB ARRAYS
MATLAB ARRAYS
 
20190907 Julia the language for future
20190907 Julia the language for future20190907 Julia the language for future
20190907 Julia the language for future
 
Cs580
Cs580Cs580
Cs580
 
Deep learning
Deep learningDeep learning
Deep learning
 
TIC-TAC-TOE IN C
TIC-TAC-TOE IN CTIC-TAC-TOE IN C
TIC-TAC-TOE IN C
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
 
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
第5回 様々なファイル形式の読み込みとデータの書き出し(解答付き)
 
Idea for ineractive programming language
Idea for ineractive programming languageIdea for ineractive programming language
Idea for ineractive programming language
 

More from 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 PolygonKasun Ranga Wijeweera
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingKasun Ranga Wijeweera
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingKasun 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
 
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

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 

Recently uploaded (20)

Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 

Digital Differential Analyzer Line Drawing Algorithm

  • 1. Computer Graphics 1 of 5 Lesson 1: Digital Differential Analyzer Line Drawing Algorithm Author: Kasun Ranga Wijeweera Email: krw19870829@gmail.com Date: 2020 June 16 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 Pseudocode of Digital Differential Analyzer Line Drawing Algorithm VOID draw (INTEGER x1, INTEGER y1, INTEGER x2, INTEGER y2) { INTEGER dx, dy, steps, k; REAL xInc, yInc, x, y; dx = x2 – x1; dy = y2 – y1; x = x1; y = y1; IF (|dx| > |dy|) steps = |dx| ELSE steps = |dy| END IF xInc = dx/steps; yInc = dy/steps; SET_PIXEL (ROUND (x), ROUND (y)); FOR (k = 1 TO steps) x = x + xInc; y = y + yInc; SET_PIXEL (ROUND (x), ROUND (y)); END FOR }
  • 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 draw (2, 3, 7, 5); dx = 7 – 2 = 5; dy = 5 – 3 = 2; x = 2; y = 3; 5 > 2 TRUE; steps = 5; xInc = 5/5 = 1; yInc = 2/5 = 0.4; SET_PIXEL (2, 3); 5 4 3 2 3 4 5 6 7
  • 4. Computer Graphics 4 of 5 k = 1 x = 2 + 1 = 3; y = 3 + 0.4 = 3.4; SET_PIXEL (3, 3); 5 4 3 2 3 4 5 6 7 k = 2 x = 3 + 1 = 4; y = 3.4 + 0.4 = 3.8; SET_PIXEL (4, 4); 5 4 3 2 3 4 5 6 7 k = 3 x = 4 + 1 = 5; y = 3.8 + 0.4 = 4.2; SET_PIXEL (5, 4); 5 4 3 2 3 4 5 6 7
  • 5. Computer Graphics 5 of 5 k = 4 x = 5 + 1 = 6; y = 4.2 + 0.4 = 4.6; SET_PIXEL (6, 5); 5 4 3 2 3 4 5 6 7 k = 5 x = 6 + 1 = 7; y = 4.6 + 0.4 = 5; SET_PIXEL (7, 5); 5 4 3 2 3 4 5 6 7