SlideShare une entreprise Scribd logo
1  sur  15
DDA Line Drawing
Algorithm
Muhammad Hamza
157101
Bioinformatics 7th
Graphics andVisualization
Presented to: Sir Muhammad Rizwan
Govt Post Graduate College Mandian
Abbottabad
Talk Sequence:
• What is Line
• Line Equation
• Slope of Line
• Examples of Drawing Line
• DDA
DDA Line Drawing Algorithm
• DDA stands for Digital Differential Analyzer
• A line drawing algorithm is a graphical algorithm for approximating a line
segment on discrete graphical media.
• This algorithm is used to draw a line on computer pixels.
What is a Line?
• A line in Computer graphics typically refers to line segment, which is a
portion of straight line that extends indefinitely in opposite direction.
• It is defined by its two end points & the slope intercept equation for a line:
y = mx + b
where, m = Slope of the line
b = the y intercept of a line
• The two endpoints of a line segment are specified at positions (x1,y1) and
(x2,y2).
Slope Conditions for Algorithms
• 1. ∆ y/ ∆ x > 1 when 0 >45
• 2. ∆ y/ ∆ x < 1 when 0 <45
• 3. ∆ y /∆ x = 1 when 0 =45
1
2
3
9
8
7
6
5
4
3
2
1
(x1,y1)(x2,y2)
(2,2) (9,2)
∆ x=9-2=7
∆ y=2-2=0
m= ∆ y/ ∆ x=0/7=0
xinc=7/7=1
yinc=0/7=0
X Y
2 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2
1 2 3 4 5 6 7 8 9 10
For Horizontal line
9
8
7
6
5
4
3
2
1
1 2 3 4 5 6 7 8 9 10
(x1,y1)(x2,y2)
(2,2) (9,2)
∆ x=9-2=7
∆ y=2-2=0
m= ∆ y/ ∆ x=0/7=0
xinc=7/7=1
yinc=0/7=0
X Y
2 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2
For Horizontal line
9
8
7
6
5
4
3
2
1
1 2 3 4 5 6 7 8 9 10
(x1,y1)(x2,y2)
(2,3) (2,8)
∆ x=2-2=0
∆ y=8-2=6
m= ∆ y/ ∆ x=6/0=∞
xinc=0/6=0
yinc=6/6=1
X Y
2 3
2 4
2 5
2 6
2 7
2 8
For Vertical line
9
8
7
6
5
4
3
2
1
1 2 3 4 5 6 7 8 9 10
(x1,y1)(x2,y2)
(2,3) (2,8)
∆ x=2-2=0
∆ y=8-2=6
m= ∆ y/ ∆ x=6/0=∞
xinc=0/6=0
yinc=6/6=1
X Y
2 3
2 4
2 5
2 6
2 7
2 8
For Vertical line
9
8
7
6
5
4
3
2
1
1 2 3 4 5 6 7 8 9 10
(x1,y1)(x2,y2)
(1,2) (9,5)
∆ x=9-1=8
∆ y=5-2=3
m= ∆ y/ ∆ x=3/8=0.37
xinc=8/8=1
yinc=3/8=0.37
X Y
1 2
2 2.37=2
3 2.74=3
4 3.11=3
5 3.48=3
6 3.85=4
7 4.22=4
8 4.59=5
9 4.96=5
For any Diagonal line
9
8
7
6
5
4
3
2
1
1 2 3 4 5 6 7 8 9 10
(x1,y1)(x2,y2)
(1,2) (9,5)
∆ x=9-1=8
∆ y=5-2=3
m= ∆ y/ ∆ x=3/8=0.37
xinc=8/8=1
yinc=3/8=0.37
X Y
1 2
2 2.37=2
3 2.74=3
4 3.11=3
5 3.48=3
6 3.85=4
7 4.22=4
8 4.59=5
9 4.96=5
For any Diagnal line
DDA Algorithm
dx-=x2-x1;
dy=y2-y1;
If(abs(dx) > abs(dy))
Steps=abs(dx);
else
Steps=abs(dy);
xinc=dx/steps;
yinc=dy/steps;
For(i-1, i<=step, i++)
{
putpixel(x1,y1);
x1=x1+xinc;
y1=y1+yinc;
}
Limitation
• There are no decimal points in coordinate system
• Time consuming because algorithm may generate floating numbers
• Line generated will not be smooth.
References:
• https://www.tutorialspoint.com/computer_graphics/line_generation_algorit
hm.htm
• http://personales.unican.es/iglesias
• https://www.geeksforgeeks.org/dda-line-generation-algorithm
• https://www.tutorialspoint.com/.../line_generation_algorithm.htm
• www.codingalpha.com/dda-line-drawing-algorithm-c-program

Contenu connexe

Tendances

Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
Mohd Arif
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
Mohd Arif
 

Tendances (20)

Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
 
Computer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithmComputer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithm
 
Output primitives computer graphics c version
Output primitives   computer graphics c versionOutput primitives   computer graphics c version
Output primitives computer graphics c version
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
 
DDA algorithm
DDA algorithmDDA algorithm
DDA algorithm
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Unit 3
Unit 3Unit 3
Unit 3
 
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Bresenham circle
Bresenham circleBresenham circle
Bresenham circle
 
Curves and surfaces
Curves and surfacesCurves and surfaces
Curves and surfaces
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Character generation techniques
Character generation techniquesCharacter generation techniques
Character generation techniques
 
Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 
Computer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methodsComputer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methods
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 

Similaire à Dda line algorithm presentatiion

A non-stiff numerical method for 3D interfacial flow of inviscid fluids.
A non-stiff numerical method for 3D interfacial flow of inviscid fluids.A non-stiff numerical method for 3D interfacial flow of inviscid fluids.
A non-stiff numerical method for 3D interfacial flow of inviscid fluids.
Alex (Oleksiy) Varfolomiyev
 
2_1 Edit Distance.pptx
2_1 Edit Distance.pptx2_1 Edit Distance.pptx
2_1 Edit Distance.pptx
tanishamahajan11
 

Similaire à Dda line algorithm presentatiion (20)

Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
SINGLE‐PHASE TO THREE‐PHASE DRIVE SYSTEM USING TWO PARALLEL SINGLE‐PHASE RECT...
SINGLE‐PHASE TO THREE‐PHASE DRIVE SYSTEM USING TWO PARALLEL SINGLE‐PHASE RECT...SINGLE‐PHASE TO THREE‐PHASE DRIVE SYSTEM USING TWO PARALLEL SINGLE‐PHASE RECT...
SINGLE‐PHASE TO THREE‐PHASE DRIVE SYSTEM USING TWO PARALLEL SINGLE‐PHASE RECT...
 
Computer Graphics Notes 2.pdf
Computer Graphics Notes 2.pdfComputer Graphics Notes 2.pdf
Computer Graphics Notes 2.pdf
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Figure Eight Curve
Figure Eight CurveFigure Eight Curve
Figure Eight Curve
 
Eight Curve Final
Eight  Curve  FinalEight  Curve  Final
Eight Curve Final
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
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
 
UNIT-II
UNIT-IIUNIT-II
UNIT-II
 
paper
paperpaper
paper
 
Lline Drawing Algorithm
Lline Drawing AlgorithmLline Drawing Algorithm
Lline Drawing Algorithm
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
 
A non-stiff numerical method for 3D interfacial flow of inviscid fluids.
A non-stiff numerical method for 3D interfacial flow of inviscid fluids.A non-stiff numerical method for 3D interfacial flow of inviscid fluids.
A non-stiff numerical method for 3D interfacial flow of inviscid fluids.
 
Calculus 45S Slides May 14, 2008
Calculus 45S Slides May 14, 2008Calculus 45S Slides May 14, 2008
Calculus 45S Slides May 14, 2008
 
2_1 Edit Distance.pptx
2_1 Edit Distance.pptx2_1 Edit Distance.pptx
2_1 Edit Distance.pptx
 
1-0b-Ch-1-Rev.ppt
1-0b-Ch-1-Rev.ppt1-0b-Ch-1-Rev.ppt
1-0b-Ch-1-Rev.ppt
 
Eight Curve[1][1]
Eight  Curve[1][1]Eight  Curve[1][1]
Eight Curve[1][1]
 
Lecture 2: Stochastic Hydrology
Lecture 2: Stochastic Hydrology Lecture 2: Stochastic Hydrology
Lecture 2: Stochastic Hydrology
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Dernier (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

Dda line algorithm presentatiion

  • 1. DDA Line Drawing Algorithm Muhammad Hamza 157101 Bioinformatics 7th Graphics andVisualization Presented to: Sir Muhammad Rizwan Govt Post Graduate College Mandian Abbottabad
  • 2. Talk Sequence: • What is Line • Line Equation • Slope of Line • Examples of Drawing Line • DDA
  • 3. DDA Line Drawing Algorithm • DDA stands for Digital Differential Analyzer • A line drawing algorithm is a graphical algorithm for approximating a line segment on discrete graphical media. • This algorithm is used to draw a line on computer pixels.
  • 4. What is a Line? • A line in Computer graphics typically refers to line segment, which is a portion of straight line that extends indefinitely in opposite direction. • It is defined by its two end points & the slope intercept equation for a line: y = mx + b where, m = Slope of the line b = the y intercept of a line
  • 5. • The two endpoints of a line segment are specified at positions (x1,y1) and (x2,y2).
  • 6. Slope Conditions for Algorithms • 1. ∆ y/ ∆ x > 1 when 0 >45 • 2. ∆ y/ ∆ x < 1 when 0 <45 • 3. ∆ y /∆ x = 1 when 0 =45 1 2 3
  • 7. 9 8 7 6 5 4 3 2 1 (x1,y1)(x2,y2) (2,2) (9,2) ∆ x=9-2=7 ∆ y=2-2=0 m= ∆ y/ ∆ x=0/7=0 xinc=7/7=1 yinc=0/7=0 X Y 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 1 2 3 4 5 6 7 8 9 10 For Horizontal line
  • 8. 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 (x1,y1)(x2,y2) (2,2) (9,2) ∆ x=9-2=7 ∆ y=2-2=0 m= ∆ y/ ∆ x=0/7=0 xinc=7/7=1 yinc=0/7=0 X Y 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 For Horizontal line
  • 9. 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 (x1,y1)(x2,y2) (2,3) (2,8) ∆ x=2-2=0 ∆ y=8-2=6 m= ∆ y/ ∆ x=6/0=∞ xinc=0/6=0 yinc=6/6=1 X Y 2 3 2 4 2 5 2 6 2 7 2 8 For Vertical line
  • 10. 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 (x1,y1)(x2,y2) (2,3) (2,8) ∆ x=2-2=0 ∆ y=8-2=6 m= ∆ y/ ∆ x=6/0=∞ xinc=0/6=0 yinc=6/6=1 X Y 2 3 2 4 2 5 2 6 2 7 2 8 For Vertical line
  • 11. 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 (x1,y1)(x2,y2) (1,2) (9,5) ∆ x=9-1=8 ∆ y=5-2=3 m= ∆ y/ ∆ x=3/8=0.37 xinc=8/8=1 yinc=3/8=0.37 X Y 1 2 2 2.37=2 3 2.74=3 4 3.11=3 5 3.48=3 6 3.85=4 7 4.22=4 8 4.59=5 9 4.96=5 For any Diagonal line
  • 12. 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 (x1,y1)(x2,y2) (1,2) (9,5) ∆ x=9-1=8 ∆ y=5-2=3 m= ∆ y/ ∆ x=3/8=0.37 xinc=8/8=1 yinc=3/8=0.37 X Y 1 2 2 2.37=2 3 2.74=3 4 3.11=3 5 3.48=3 6 3.85=4 7 4.22=4 8 4.59=5 9 4.96=5 For any Diagnal line
  • 13. DDA Algorithm dx-=x2-x1; dy=y2-y1; If(abs(dx) > abs(dy)) Steps=abs(dx); else Steps=abs(dy); xinc=dx/steps; yinc=dy/steps; For(i-1, i<=step, i++) { putpixel(x1,y1); x1=x1+xinc; y1=y1+yinc; }
  • 14. Limitation • There are no decimal points in coordinate system • Time consuming because algorithm may generate floating numbers • Line generated will not be smooth.
  • 15. References: • https://www.tutorialspoint.com/computer_graphics/line_generation_algorit hm.htm • http://personales.unican.es/iglesias • https://www.geeksforgeeks.org/dda-line-generation-algorithm • https://www.tutorialspoint.com/.../line_generation_algorithm.htm • www.codingalpha.com/dda-line-drawing-algorithm-c-program