SlideShare una empresa de Scribd logo
1 de 11
Computer Graphics
PRESENTATION
Presenter :
• Aashish Adhikari
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
• Digital Differential Analyzer (DDA) Algorithm
a. Working Principle
b. Examples
• Bresenham’s Line Drawing Algorithm (BSA)
a. Working Principle
b. Examples
Contents
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Working Principle of DDA Algorithm
Algorithm
Step 1: Input the line endpoints and store the left endpoint in (x0, y0) and right endpoint in (x1, y1).
Step 2: Calculate the values of Δx and Δy,
Δx = x1 – x0, Δy = y1 – y0
Step 3: Based on the calculated difference in step 2, now we need to identify the number of steps
to put pixel as follows:
If Δx > Δy, then we need more steps in x co-ordinate; otherwise in y
coordinate.
I.e. if (absolute(Δx) > absolute (Δy) ), then steps = absolute(Δx) else steps =
absolute(Δy)
Step 4: We calculate the increment in x coordinate and y coordinate as follows:
xincreament =
Δx
𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡
Yincreament =
Δy
𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡
Step 5: Perform round off, and plot each calculated (x, y) i.e. Plot(round(x), round(y)).
Step 6: END
Definition: The Digital Differential Analyzer(DDA) is a scan conversion line drawing algorithm based on calculating
either Δx or Δy from the equation m = Δy/Δx.
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Example 1 : ( For m<1 OR Δx>Δy)
* Using DDA Plot (5,4) to (12,7)
Solution:
Given,
(x0, y0) = ( 5,4)
(x1, y1) = ( 12,7)
Δx = x1 – x0 = 12-5 = 7
Δy = y1 – y0 = 7-4 = 3
Since, Δx > Δy or, Slope m=
Δy
Δx
=
3
7
i.e. <1
So, no. of Steps= absolute (Δx)
= |7| = 7
Now,
xincreament =
Δx
𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡
=
7
7
= 1
Yincreament =
Δy
𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡
=
3
7
= 0.4
Steps X Y Y(Rounded off)
0 5 4 4
1 6 4.4 4
2 7 4.8 5
3 8 5.2 5
4 9 5.6 6
5 10 6 6
6 11 6.4 6
7 12 6.8 7
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Example 2 : ( For m>1 OR Δx<Δy)
* Using DDA Plot (5,7) to (10,15)
Solution:
Given,
(x0, y0) = ( 5,7)
(x1, y1) = ( 10,15)
Δx = x1 – x0 = 10-5 = 5
Δy = y1 – y0 =15-7 = 8
Since, Δx < Δy or, Slope m=
Δy
Δx
=
8
5
i.e. >1
So, no. of Steps= absolute (Δy)
= |8| = 8
Now,
xincreament =
Δx
𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡
=
5
8
= 0.6
Yincreament =
Δy
𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡
=
8
8
=1
Steps X Y Y(Rounded off)
0 5 7 5
1 5.6 8 6
2 6.2 9 6
3 6.8 10 7
4 7.4 11 7
5 8 12 8
6 8.6 13 9
7 9.2 14 9
8 9.8 15 10
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Working Principle of Bresenham’s Line Drawing
Algorithm (BSA) [for positive slope questions]
Definition: An accurate and efficient raster line-drawing algorithm, developed by Bresenham‘s. It only uses integer
calculations so can be adapted to display circles and other curves.
AlgorithmAlgorithm
Step 1: Input the line endpoints and store the left
endpoint in (x0, y0) and right endpoint in (x1, y1).
Step 2: Calculate the values of Δx and Δy,
Δx = abs(x1 – x0), Δy = abs(y1 – y0)
Step 3: Calculate initial decision parameter as,
p = 2 Δy- Δx
Step 4: if x1 > x0 then
Set x= x0
Set y=y0
Set xend=x1
Otherwise
Set x= x1
Set y=y1
Set xend=x0
Step 5: Draw pixel at (x,y)
Step 6: while(x<xend)
x++;
if p<0 then
p=p+2Δy
Otherwise
y++
p=p+2Δy-2Δx
Draw pixel at (x,y)
Step 7: END
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Example 1 : ( For m<=1 OR Δx>Δy)
* Digitize a line with end points (10,15) to (15,18) using BSA
Solution:
Given,
(x0, y0) = ( 10,15)
(x1, y1) = ( 15,18)
Δx = x1 – x0 = |15-10| = 5
Δy = y1 – y0 = |18-15| = 3
Since, Slope m=
Δy
Δx
<=1
So, we sample at x direction i.e., at each step we simply increment x-coordinate by 1 and find appropriate y-coordinate.
First pixel to plot is (10,15), which is the starting endpoint.
Now, initial decision parameter, p0 = 2 Δy- Δx = 2*3-5 = 1
We know that,
If pk < 0, then we need to set pk+1 = pk+2△y and plot pixel(xk+1, yk)
And if pk ≥ 0, then we need to set pk+1 = pk + 2 △y – 2 △x then plot pixel(xk+1, yk+1)
Here p0 = 1, we have i.e., pk ≥0
So,
p1 = p0 + 2 △y – 2 △x = 1 + 2 * 3 – 2 x 5 = -3
p2 = p1+ 2 △y = -3+2 * 3 = 3.
p3 = p2 + 2 △y – 2 △x = 3+6-10 = -1.
p4 = p3 + 2 △y = -1+ 6 = 5
Successive pixel positions and decision parameter calculation is shown in the table.
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Working Principle of Bresenham’s Line Drawing
Algorithm (BSA) [for negative slope questions]
Algorithm
Step 1: Input the line endpoints and store the left endpoint in (x0, y0) and right endpoint in (x1, y1).
Step 2: Calculate the values of Δx and Δy,
Δx = abs(x1 – x0),
Δy = abs(y1 – y0)
Step 3: Calculate initial decision parameter as,
pk = 2 Δy- Δx
Step 4: for (i=1 to Δx)
{
set pixel (xs, ys)
while (pk>0)
y0=y0-1;
pk= pk-2 Δx
end while, (pk>0)
x0=x0+1
pk= pk+2 Δy
i++;
}
set pixel (x0, y0)
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Example 2 : ( For m>=1 OR Δx>Δy)
* Digitize a line with end points (6,12) to (10,5) using BSA
Solution:
Given,
(x0, y0) = ( 6,12), (x1, y1) = ( 10,05)
Now, We calculate the Δx and Δy as follows:
Δx = x1 – x0 = |10-6| = 4, Δy = y1 – y0 = |5-12| = 7
Since, Slope m=
Δy
Δx
>=1
So, we sample at x direction i.e., at each step we simply increment x-coordinate by 1 and find appropriate y-coordinate.
First pixel to plot is (10,15), which is the starting endpoint.
Now, initial decision parameter, p0 = 2 Δy- Δx = 2*7-4 = 10
For (i=1 to 4) using the condition we proceed as follows:
For i=1
set pixel (6,12) while (10>0)
y0= 12-1 = 11
pk= 10-2*4 = 2
while (2>0)
y0= 11-1 =10
pk= 2-2*4 = -6
end while
x0= x0+1 = 6+1 = 7
pk = pk+ 2 Δy
= -6+2*7 = 8
Successive pixel positions and decision parameter calculation is shown in the table.
I X0 Y0 Pk Points
1 6 12 10 (7,10)
2 7 10 8 (8,9)
3 8 9 14 (9,7)
4 9 7 12 (10,5)
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Working Principle of Bresenham’s Line Drawing Algorithm (BSA) [for negative
slope questions]
* Digitize a line with end points (6,12) to (10,5) using BSA
( For m>=1 OR Δx>Δy)
Alternative Method
AASHISH ADHIKARI [mail@aashishadhikari.info.np]
Thanks
2020.04.19
AASHISH ADHIKARI [mail@aashishadhikari.info.np]

Más contenido relacionado

La actualidad más candente

Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiTekendra Nath Yogi
 
Graphics pipelining
Graphics pipeliningGraphics pipelining
Graphics pipeliningAreena Javed
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithmnehrurevathy
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithmAparna Joshi
 
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
 
knapsack problem
knapsack problemknapsack problem
knapsack problemAdnan Malak
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithmAnkit Garg
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)Timbal Mayank
 
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm Aparna Joshi
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithmfarimoin
 
Python Pandas
Python PandasPython Pandas
Python PandasSunil OS
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse2013901097
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab FileKandarp Tiwari
 

La actualidad más candente (20)

Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Bresenham algorithm
Bresenham algorithmBresenham algorithm
Bresenham algorithm
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
 
Graphics pipelining
Graphics pipeliningGraphics pipelining
Graphics pipelining
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Bresenham circle
Bresenham circleBresenham circle
Bresenham circle
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
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
 
knapsack problem
knapsack problemknapsack problem
knapsack problem
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 
Python Pandas
Python PandasPython Pandas
Python Pandas
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
Unit 1
Unit 1Unit 1
Unit 1
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab File
 

Similar a Working principle of dda and bresenham line drawing explaination with example

Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesAnkit Garg
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxKokebe2
 
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptxdddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptxSubramaniyanChandras1
 
DDA (Digital Differential Analyzer ) Line Drawing Algorithm.pptx
DDA (Digital Differential Analyzer ) Line Drawing Algorithm.pptxDDA (Digital Differential Analyzer ) Line Drawing Algorithm.pptx
DDA (Digital Differential Analyzer ) Line Drawing Algorithm.pptxhasibulhamim1
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4Roziq Bahtiar
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2SanthiNivas
 
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...Saikrishna Tanguturu
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivationKumar
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivationMuhammad Fiaz
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfmeenasp
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxNaveenaKarthik3
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimediasaranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivessaranyan75
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing DesignV Tripathi
 

Similar a Working principle of dda and bresenham line drawing explaination with example (20)

Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptxdddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
 
Math is fun!
Math is fun!Math is fun!
Math is fun!
 
DDA (Digital Differential Analyzer ) Line Drawing Algorithm.pptx
DDA (Digital Differential Analyzer ) Line Drawing Algorithm.pptxDDA (Digital Differential Analyzer ) Line Drawing Algorithm.pptx
DDA (Digital Differential Analyzer ) Line Drawing Algorithm.pptx
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
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...
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdf
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
 
Dda algo notes
Dda algo notesDda algo notes
Dda algo notes
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
 

Último

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 

Último (20)

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 

Working principle of dda and bresenham line drawing explaination with example

  • 1. Computer Graphics PRESENTATION Presenter : • Aashish Adhikari AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 2. • Digital Differential Analyzer (DDA) Algorithm a. Working Principle b. Examples • Bresenham’s Line Drawing Algorithm (BSA) a. Working Principle b. Examples Contents AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 3. Working Principle of DDA Algorithm Algorithm Step 1: Input the line endpoints and store the left endpoint in (x0, y0) and right endpoint in (x1, y1). Step 2: Calculate the values of Δx and Δy, Δx = x1 – x0, Δy = y1 – y0 Step 3: Based on the calculated difference in step 2, now we need to identify the number of steps to put pixel as follows: If Δx > Δy, then we need more steps in x co-ordinate; otherwise in y coordinate. I.e. if (absolute(Δx) > absolute (Δy) ), then steps = absolute(Δx) else steps = absolute(Δy) Step 4: We calculate the increment in x coordinate and y coordinate as follows: xincreament = Δx 𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡 Yincreament = Δy 𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡 Step 5: Perform round off, and plot each calculated (x, y) i.e. Plot(round(x), round(y)). Step 6: END Definition: The Digital Differential Analyzer(DDA) is a scan conversion line drawing algorithm based on calculating either Δx or Δy from the equation m = Δy/Δx. AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 4. Example 1 : ( For m<1 OR Δx>Δy) * Using DDA Plot (5,4) to (12,7) Solution: Given, (x0, y0) = ( 5,4) (x1, y1) = ( 12,7) Δx = x1 – x0 = 12-5 = 7 Δy = y1 – y0 = 7-4 = 3 Since, Δx > Δy or, Slope m= Δy Δx = 3 7 i.e. <1 So, no. of Steps= absolute (Δx) = |7| = 7 Now, xincreament = Δx 𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡 = 7 7 = 1 Yincreament = Δy 𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡 = 3 7 = 0.4 Steps X Y Y(Rounded off) 0 5 4 4 1 6 4.4 4 2 7 4.8 5 3 8 5.2 5 4 9 5.6 6 5 10 6 6 6 11 6.4 6 7 12 6.8 7 AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 5. Example 2 : ( For m>1 OR Δx<Δy) * Using DDA Plot (5,7) to (10,15) Solution: Given, (x0, y0) = ( 5,7) (x1, y1) = ( 10,15) Δx = x1 – x0 = 10-5 = 5 Δy = y1 – y0 =15-7 = 8 Since, Δx < Δy or, Slope m= Δy Δx = 8 5 i.e. >1 So, no. of Steps= absolute (Δy) = |8| = 8 Now, xincreament = Δx 𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡 = 5 8 = 0.6 Yincreament = Δy 𝑆𝑡𝑒𝑝𝑠 𝑓𝑙𝑜𝑎𝑡 = 8 8 =1 Steps X Y Y(Rounded off) 0 5 7 5 1 5.6 8 6 2 6.2 9 6 3 6.8 10 7 4 7.4 11 7 5 8 12 8 6 8.6 13 9 7 9.2 14 9 8 9.8 15 10 AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 6. Working Principle of Bresenham’s Line Drawing Algorithm (BSA) [for positive slope questions] Definition: An accurate and efficient raster line-drawing algorithm, developed by Bresenham‘s. It only uses integer calculations so can be adapted to display circles and other curves. AlgorithmAlgorithm Step 1: Input the line endpoints and store the left endpoint in (x0, y0) and right endpoint in (x1, y1). Step 2: Calculate the values of Δx and Δy, Δx = abs(x1 – x0), Δy = abs(y1 – y0) Step 3: Calculate initial decision parameter as, p = 2 Δy- Δx Step 4: if x1 > x0 then Set x= x0 Set y=y0 Set xend=x1 Otherwise Set x= x1 Set y=y1 Set xend=x0 Step 5: Draw pixel at (x,y) Step 6: while(x<xend) x++; if p<0 then p=p+2Δy Otherwise y++ p=p+2Δy-2Δx Draw pixel at (x,y) Step 7: END AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 7. Example 1 : ( For m<=1 OR Δx>Δy) * Digitize a line with end points (10,15) to (15,18) using BSA Solution: Given, (x0, y0) = ( 10,15) (x1, y1) = ( 15,18) Δx = x1 – x0 = |15-10| = 5 Δy = y1 – y0 = |18-15| = 3 Since, Slope m= Δy Δx <=1 So, we sample at x direction i.e., at each step we simply increment x-coordinate by 1 and find appropriate y-coordinate. First pixel to plot is (10,15), which is the starting endpoint. Now, initial decision parameter, p0 = 2 Δy- Δx = 2*3-5 = 1 We know that, If pk < 0, then we need to set pk+1 = pk+2△y and plot pixel(xk+1, yk) And if pk ≥ 0, then we need to set pk+1 = pk + 2 △y – 2 △x then plot pixel(xk+1, yk+1) Here p0 = 1, we have i.e., pk ≥0 So, p1 = p0 + 2 △y – 2 △x = 1 + 2 * 3 – 2 x 5 = -3 p2 = p1+ 2 △y = -3+2 * 3 = 3. p3 = p2 + 2 △y – 2 △x = 3+6-10 = -1. p4 = p3 + 2 △y = -1+ 6 = 5 Successive pixel positions and decision parameter calculation is shown in the table. AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 8. Working Principle of Bresenham’s Line Drawing Algorithm (BSA) [for negative slope questions] Algorithm Step 1: Input the line endpoints and store the left endpoint in (x0, y0) and right endpoint in (x1, y1). Step 2: Calculate the values of Δx and Δy, Δx = abs(x1 – x0), Δy = abs(y1 – y0) Step 3: Calculate initial decision parameter as, pk = 2 Δy- Δx Step 4: for (i=1 to Δx) { set pixel (xs, ys) while (pk>0) y0=y0-1; pk= pk-2 Δx end while, (pk>0) x0=x0+1 pk= pk+2 Δy i++; } set pixel (x0, y0) AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 9. Example 2 : ( For m>=1 OR Δx>Δy) * Digitize a line with end points (6,12) to (10,5) using BSA Solution: Given, (x0, y0) = ( 6,12), (x1, y1) = ( 10,05) Now, We calculate the Δx and Δy as follows: Δx = x1 – x0 = |10-6| = 4, Δy = y1 – y0 = |5-12| = 7 Since, Slope m= Δy Δx >=1 So, we sample at x direction i.e., at each step we simply increment x-coordinate by 1 and find appropriate y-coordinate. First pixel to plot is (10,15), which is the starting endpoint. Now, initial decision parameter, p0 = 2 Δy- Δx = 2*7-4 = 10 For (i=1 to 4) using the condition we proceed as follows: For i=1 set pixel (6,12) while (10>0) y0= 12-1 = 11 pk= 10-2*4 = 2 while (2>0) y0= 11-1 =10 pk= 2-2*4 = -6 end while x0= x0+1 = 6+1 = 7 pk = pk+ 2 Δy = -6+2*7 = 8 Successive pixel positions and decision parameter calculation is shown in the table. I X0 Y0 Pk Points 1 6 12 10 (7,10) 2 7 10 8 (8,9) 3 8 9 14 (9,7) 4 9 7 12 (10,5) AASHISH ADHIKARI [mail@aashishadhikari.info.np]
  • 10. Working Principle of Bresenham’s Line Drawing Algorithm (BSA) [for negative slope questions] * Digitize a line with end points (6,12) to (10,5) using BSA ( For m>=1 OR Δx>Δy) Alternative Method AASHISH ADHIKARI [mail@aashishadhikari.info.np]