SlideShare a Scribd company logo
1 of 16
Download to read offline
LINE DRAWING
ALGORITHM
NEHRUREVATHY
DEPARTMENT OF BCA
DDA ALGORITHM:
• DDA stands for Digital Differential Analyzer.
• It is an incremental method of scan conversion of line.
• In this method calculation is performed at each step but by
using results of previous steps.
• Suppose at step-1, the pixels is (xi,yi)
• The line of equation for step-1
y1=mx1+b......................equation (1)
DDA ALGORITHM:
• Next value will be
y2=mx2+b.................equation 2
• For any x interval,∆x,
∆y=m∆x
• For any y interval,∆y,
∆x=∆y/m
DDA ALGORITHM:
• Slope Interval- Three conditions:
1.|m| < 1 ------ Draw a horizontal line
2.|m| > 1 ------ Draw a vertical line
3.|m| = 1 ------ Draw a horizontal line or vertical line
DDA ALGORITHM:
• Consider the slope as three cases :
• Case1: If slope m<=1 at x interval------yk+1=yk+m
• Case2:If slope m>=1 at x interval------xk+1=xk+1/m
• Case3:If ∆x=-1 and ∆y=-1-----------yk+1=yk-m and xk+1=xk-1/m
DDA ALGORITHM:
• DDA Algorithm:
Step1: Start Algorithm
Step2: Declare x1,y1,x2,y2,dx,dy,x,y as integer variables.
Step3: Enter value of x1,y1,x2,y2.
Step4: Calculate dx = x2-x1
Step5: Calculate dy = y2-y1
DDA ALGORITHM:
Step6: If ABS (dx) > ABS (dy)
Then step = abs (dx)
Else
Step7: xinc=dx/step
yinc=dy/step
assign x = x1
assign y = y1
Step8: Set pixel (x, y)
DDA ALGORITHM:
Step9: x = x + xinc
y = y + yinc
Set pixels (Round (x), Round (y))
Step10: Repeat step 9 until x = x2
Step11: End Algorithm
Example: If a line is drawn from (2, 3) to (6, 15) with use of DDA.
How many points will needed to generate such line?
DDA ALGORITHM-Example:
Solution: P1 (2,3) P2(6,15)
x1=2
y1=3
x2= 6
y2=15
dx = 6 - 2 = 4
dy = 15 - 3 = 12
m = dx/dy=12/4
DDA ALGORITHM-Example:
For calculating next value of x takes x = x + 1/m
DDA ALGORITHM-Example:
Advantage:
• It is a faster method than method of using direct use of line equation.
• This method does not use multiplication theorem.
• It allows us to detect the change in the value of x and y ,so plotting of
same point twice is not possible.
• This method gives overflow indication when a point is repositioned.
• It is an easy method because each step involves just two additions
Disadvantage:
• It involves floating point additions rounding off is done.
• Rounding off operations and floating point operations consumes
a lot of time.
• It is more suitable for generating line using the software. But it is
less suited for hardware implementation
DDA ALGORITHM
procedure DDA( x1, y1, x2, y2: integer);
var
dx, dy, steps: integer;
x_inc, y_inc, x, y: real;
begin
dx := x2 - x1; dy := y2 - y1;
if abs(dx) > abs(dy) then
steps := abs(dx); {steps is larger of dx, dy}
DDA ALGORITHM
else
steps := abs(dy);
x_inc := dx/steps; y_inc := dy/steps;
{either x_inc or y_inc = 1.0, the other is the slope}
x:=x1; y:=y1;
set_pixel(round(x), round(y));
for i := 1 to steps do
DDA ALGORITHM
begin
x := x + x_inc;
y := y + y_inc;
set_pixel(round(x), round(y));
end;
end; {DDA}

More Related Content

What's hot

Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithmnehrurevathy
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesAnkit Garg
 
Computer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithmComputer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithmRuchi Maurya
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
Matrix Manipulation in Matlab
Matrix Manipulation in MatlabMatrix Manipulation in Matlab
Matrix Manipulation in MatlabMohamed Loey
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmMahesh Kodituwakku
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
Graphing Functions and Their Transformations
Graphing Functions and Their TransformationsGraphing Functions and Their Transformations
Graphing Functions and Their Transformationszacho1c
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplicationRespa Peter
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 

What's hot (20)

BRESENHAM’S LINE DRAWING ALGORITHM
BRESENHAM’S  LINE DRAWING ALGORITHMBRESENHAM’S  LINE DRAWING ALGORITHM
BRESENHAM’S LINE DRAWING ALGORITHM
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
Computer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithmComputer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithm
 
Dda algo notes
Dda algo notesDda algo notes
Dda algo notes
 
Unit 3
Unit 3Unit 3
Unit 3
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Lect14 lines+circles
Lect14 lines+circlesLect14 lines+circles
Lect14 lines+circles
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
 
Lect3cg2011
Lect3cg2011Lect3cg2011
Lect3cg2011
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Dda line-algorithm
Dda line-algorithmDda line-algorithm
Dda line-algorithm
 
Matrix Manipulation in Matlab
Matrix Manipulation in MatlabMatrix Manipulation in Matlab
Matrix Manipulation in Matlab
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Introduction to curve
Introduction to curveIntroduction to curve
Introduction to curve
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Graphing Functions and Their Transformations
Graphing Functions and Their TransformationsGraphing Functions and Their Transformations
Graphing Functions and Their Transformations
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 

Similar to Lline Drawing Algorithm

Line drawing Algorithm DDA in computer Graphics.pdf
Line drawing Algorithm DDA in computer Graphics.pdfLine drawing Algorithm DDA in computer Graphics.pdf
Line drawing Algorithm DDA in computer Graphics.pdfRAJARATNAS
 
1536 graphics &amp; graphical programming
1536 graphics &amp; graphical  programming1536 graphics &amp; graphical  programming
1536 graphics &amp; graphical programmingDr Fereidoun Dejahang
 
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
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfRajJain516913
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygonsaa11bb11
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons dericationKumar
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxNaveenaKarthik3
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfmeenasp
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsAmol Gaikwad
 
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarComputer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarVishal Butkar
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1aravindangc
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptGaganvirKaur
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
CHAPTER 7.pdfdjdjdjdjdjdjdjsjsjddhhdudsko
CHAPTER 7.pdfdjdjdjdjdjdjdjsjsjddhhdudskoCHAPTER 7.pdfdjdjdjdjdjdjdjsjsjddhhdudsko
CHAPTER 7.pdfdjdjdjdjdjdjdjsjsjddhhdudskoSydneyJaydeanKhanyil
 
141031_Lagrange Relaxation Based Method for the QoS Routing Problem
141031_Lagrange Relaxation Based Method for the QoS Routing Problem 141031_Lagrange Relaxation Based Method for the QoS Routing Problem
141031_Lagrange Relaxation Based Method for the QoS Routing Problem Eunice Lin
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptxAhmadAbba6
 

Similar to Lline Drawing Algorithm (20)

Line drawing Algorithm DDA in computer Graphics.pdf
Line drawing Algorithm DDA in computer Graphics.pdfLine drawing Algorithm DDA in computer Graphics.pdf
Line drawing Algorithm DDA in computer Graphics.pdf
 
1536 graphics &amp; graphical programming
1536 graphics &amp; graphical  programming1536 graphics &amp; graphical  programming
1536 graphics &amp; graphical programming
 
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
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdf
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
 
UNIT-II
UNIT-IIUNIT-II
UNIT-II
 
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarComputer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.ppt
 
Deep Learning
Deep LearningDeep Learning
Deep Learning
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
CHAPTER 7.pdfdjdjdjdjdjdjdjsjsjddhhdudsko
CHAPTER 7.pdfdjdjdjdjdjdjdjsjsjddhhdudskoCHAPTER 7.pdfdjdjdjdjdjdjdjsjsjddhhdudsko
CHAPTER 7.pdfdjdjdjdjdjdjdjsjsjddhhdudsko
 
141031_Lagrange Relaxation Based Method for the QoS Routing Problem
141031_Lagrange Relaxation Based Method for the QoS Routing Problem 141031_Lagrange Relaxation Based Method for the QoS Routing Problem
141031_Lagrange Relaxation Based Method for the QoS Routing Problem
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
 
03.Scan Conversion.ppt
03.Scan Conversion.ppt03.Scan Conversion.ppt
03.Scan Conversion.ppt
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 

More from nehrurevathy

Revision 3 updated
Revision 3 updatedRevision 3 updated
Revision 3 updatednehrurevathy
 
CATHODE RAY TUBE IN COMPUTER GRAPHICS
CATHODE RAY TUBE IN COMPUTER GRAPHICSCATHODE RAY TUBE IN COMPUTER GRAPHICS
CATHODE RAY TUBE IN COMPUTER GRAPHICSnehrurevathy
 
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICSATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICSnehrurevathy
 
2D- Transformation
2D- Transformation2D- Transformation
2D- Transformationnehrurevathy
 
COLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSCOLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSnehrurevathy
 

More from nehrurevathy (6)

Clipping
ClippingClipping
Clipping
 
Revision 3 updated
Revision 3 updatedRevision 3 updated
Revision 3 updated
 
CATHODE RAY TUBE IN COMPUTER GRAPHICS
CATHODE RAY TUBE IN COMPUTER GRAPHICSCATHODE RAY TUBE IN COMPUTER GRAPHICS
CATHODE RAY TUBE IN COMPUTER GRAPHICS
 
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICSATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
 
2D- Transformation
2D- Transformation2D- Transformation
2D- Transformation
 
COLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSCOLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICS
 

Recently uploaded

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
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 17Celine George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
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)Jisc
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
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.pptxDenish Jangid
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
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 POSCeline George
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
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.christianmathematics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 

Recently uploaded (20)

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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)
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
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
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
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
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
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.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Lline Drawing Algorithm

  • 2. DDA ALGORITHM: • DDA stands for Digital Differential Analyzer. • It is an incremental method of scan conversion of line. • In this method calculation is performed at each step but by using results of previous steps. • Suppose at step-1, the pixels is (xi,yi) • The line of equation for step-1 y1=mx1+b......................equation (1)
  • 3. DDA ALGORITHM: • Next value will be y2=mx2+b.................equation 2 • For any x interval,∆x, ∆y=m∆x • For any y interval,∆y, ∆x=∆y/m
  • 4. DDA ALGORITHM: • Slope Interval- Three conditions: 1.|m| < 1 ------ Draw a horizontal line 2.|m| > 1 ------ Draw a vertical line 3.|m| = 1 ------ Draw a horizontal line or vertical line
  • 5. DDA ALGORITHM: • Consider the slope as three cases : • Case1: If slope m<=1 at x interval------yk+1=yk+m • Case2:If slope m>=1 at x interval------xk+1=xk+1/m • Case3:If ∆x=-1 and ∆y=-1-----------yk+1=yk-m and xk+1=xk-1/m
  • 6. DDA ALGORITHM: • DDA Algorithm: Step1: Start Algorithm Step2: Declare x1,y1,x2,y2,dx,dy,x,y as integer variables. Step3: Enter value of x1,y1,x2,y2. Step4: Calculate dx = x2-x1 Step5: Calculate dy = y2-y1
  • 7. DDA ALGORITHM: Step6: If ABS (dx) > ABS (dy) Then step = abs (dx) Else Step7: xinc=dx/step yinc=dy/step assign x = x1 assign y = y1 Step8: Set pixel (x, y)
  • 8. DDA ALGORITHM: Step9: x = x + xinc y = y + yinc Set pixels (Round (x), Round (y)) Step10: Repeat step 9 until x = x2 Step11: End Algorithm Example: If a line is drawn from (2, 3) to (6, 15) with use of DDA. How many points will needed to generate such line?
  • 9. DDA ALGORITHM-Example: Solution: P1 (2,3) P2(6,15) x1=2 y1=3 x2= 6 y2=15 dx = 6 - 2 = 4 dy = 15 - 3 = 12 m = dx/dy=12/4
  • 10. DDA ALGORITHM-Example: For calculating next value of x takes x = x + 1/m
  • 12. Advantage: • It is a faster method than method of using direct use of line equation. • This method does not use multiplication theorem. • It allows us to detect the change in the value of x and y ,so plotting of same point twice is not possible. • This method gives overflow indication when a point is repositioned. • It is an easy method because each step involves just two additions
  • 13. Disadvantage: • It involves floating point additions rounding off is done. • Rounding off operations and floating point operations consumes a lot of time. • It is more suitable for generating line using the software. But it is less suited for hardware implementation
  • 14. DDA ALGORITHM procedure DDA( x1, y1, x2, y2: integer); var dx, dy, steps: integer; x_inc, y_inc, x, y: real; begin dx := x2 - x1; dy := y2 - y1; if abs(dx) > abs(dy) then steps := abs(dx); {steps is larger of dx, dy}
  • 15. DDA ALGORITHM else steps := abs(dy); x_inc := dx/steps; y_inc := dy/steps; {either x_inc or y_inc = 1.0, the other is the slope} x:=x1; y:=y1; set_pixel(round(x), round(y)); for i := 1 to steps do
  • 16. DDA ALGORITHM begin x := x + x_inc; y := y + y_inc; set_pixel(round(x), round(y)); end; end; {DDA}