SlideShare a Scribd company logo
1 of 31
OUTPUT PRIMITIVES
Mrs.G.ALAMELU,MCA.,M.PHIL.,
EMG YADAVA WOMEN’S COLLEGE,
POINTS AND LINES:
A line connects two points. It is a basic element in
graphics.
To draw a line, you need two points between
which youcandraw aline.
In the following three algorithms, we refer the
one point of line as X0,Y0 and the second point of
lineasX1,Y1.
Apointisadimensionlessshape,sinceitrepresentsadotonly,
whereasalineisaone-dimensionalshape.
Pointsisthefundamentalelementof picturerepresentation.
Two points represent line or edge and 3 or more points a
polygon.
Curvedlinesarerepresentedbytheshort straightlines.
It is the position in the plan defined as either pair or triplets of
numberdependinguponthedimension.
LINE-DRAWING ALGORITHMS:
The process of ”turing on” the pixels for a line segment is
called vector generation or line generation,and the
algorithms for them are known as vector generation
algorithmsorlinedrawingalgorithms.
Before discussing specific line drawing algorithms it is
useful to note the general requirements for such
algorithms.
The cartesian slope-intercept equation for a straight line
is y=m.x+b
Slopeofthelinem= y2-y1/x2-x1
Interceptbwith b=y1-m.x1
 The line should appears as a straight line and it
shouldstartandendaccurately.
 The line should be displayed with constant
brightness alongit
 lengthandorientation.
 Thelineshouldbedrawnrapidly
Theserequirementspecifythedesiredcharacteristicsofline:
 Input: At least one or more inputs must be accept a good
algorithm.
 Output:Atleastoneoutputmustproducedanalgorithm.
 An algorithm should be precise: The algorithm’s each step
mustwell-define.
 Finiteness: Finiteness is require in an algorithm. It signifies
that the algorithm will come to a halt once all of the steps
havebeencomplete.
PropertiesofaLineDrawing Algorithm:
 Correctness: An algorithm must implemented
correctly.
 Uniqueness: The result of an algorithm should be
basedonthe given input, andall stepsof the algorithm
shouldbeclearlyanduniquelydefined.
 Effectiveness: An algorithm’s steps must be correct
andefficient.
 Easy to understand: Learners must be able to
understand the solution in a more natural way thanks
toanalgorithm.
DDA ALGORITHM:
The digital differential analyser(DDA) is a scan-
conversion line algorithm based on calculating
either ∆yor ∆x.
A linear DDA starts by calculating the smaller of dy
or dxforaunitincrementof theother.
It is a simple and efficient algorithm that works by
using the incremental difference between the x-
coordinates and y-coordinates of the two endpoints
toplot theline.
 Thetwo endpointsof thelinesegment, (x1,y1) and(x2,y2).
 Calculate thedifference between thex-coordinates andy-
coordinates oftheendpoints asdxand dyrespectively.
 Calculate theslope ofthe lineasm= dy/dx.
 Set theinitialpointofthelineas(x1,y1).
 Loopthroughthe x-coordinates of theline,incrementingbyone
eachtime, andcalculatethecorresponding y-coordinateusing
theequationy=y1+m(x –x1).
 Plot thepixelatthecalculated(x,y) coordinate.
 Repeat steps 5and6untiltheendpoint(x2,y2) isreached.
Asteps involved inDDAlinegenerationalgorithmare:
 Sample at unit x intervals(∆x = 1) and compute each successive y
valueas yk+1 =yk +m.
 Sample at unit y intervals(∆y = 1) and compute each succeeding x
valueas xk+1 =xk + 1/m.
 If this processing is reversed,so that the starting ebdpoint is at
right,then either∆x=-1
 If absolute value of the slope is less than 1 and the start endpoint is at
theleft, ∆x=1
The digital differential analyser(DDA) is a scan-conversion line algorithm
based oncalculatingeither∆yor ∆x.
A linear DDA starts by calculating the smaller of dy or dx for a unit
incrementof the other.
It is a simple and efficient algorithm that works by using the incremental
difference between the x-coordinates and y-coordinates of the two
endpoints to plotthe line.
BRESENHAM’S LINE ALGORITHM:
The main task is to find all the intermediate points required
fordrawinglineABonthecomputerscreen of pixels.
In this algorithm, every pixel has integer coordinates. Apart
from that, the Bresenham algorithm works on addition and
subtractionoperations.
This algorithmis usedforscanconvertingaline.
It’s a line drawing algorithm that determines the points of
an n-dimensional raster that should be selected in order
to form a close approximation to a straight line between
two points.
Bresenham's algorithm - a fundamental method in
Computer Graphics - is a clever way of approximating a
continuous straight line with discrete pixels, ensuring
that the line appears straight and smooth on a pixel-
based display.
Points meant by group of pixels.
So, d_upperandd_lower aregivenasfollows:
d_lower =y-yk
=m*(xk+1)+ b-yk
d_upper=(yk + 1)-y
=yk + 1-m*(xk +1) -b
 Slope formula:y=m(xk +1)+b
 Thedifference between two-pixel places served thebasis forthis
straightforward decision:
d_lower -d_upper=2m(xk +1) - 2yk +2b -1
 Let’ssubstitute mwith ∆y/∆xwhere ∆xand∆yarethedifferences
between theendpoints:
∆x(d_lower -d_upper)=∆x( (2∆y/∆x)(xk +1)-2yk) +(2b -1)
=2∆y.xk -2∆x.yk +2∆y +∆x(2b -1)
=2∆y.xk -2∆x.yk + c
 So, atthekthstep alongaline, adecisionparameterpk isgivenby:
pk=∆x(d_upper-d_lower)
=2∆y.xk -2∆x.yk +c
 Thevalues ofsuccessive decisionparameters using
incremental integercalculation.Atstep k+1, the decision
parameterisevaluated from as:
pk+1=2∆y.(xk+1) -2∆x.(yk+1) + c
 From thepreceding equation:
pk+1 -pk =2∆y.(xk+1 - xk) -2∆x (yk+1 -yk)
 But xk+1= xk +1
pk+1 =pk +2∆y -2∆x(yk+1 -yk)
Whereyk+1-yk iseither 0or1dependingonthe
signofpk
Theinitialdecisionparameterp0 isevaluated at
(x0,y0)andiswritten asfollows:
p0 =2∆y-∆x
 Bresenham Line drawing algorithm is used for scan converting a line. It is an
efficient method because it involves integer addition, subtraction, and
multiplication operations. Because these actions may be completed quickly,
linescanbegenerated quickly.
Inputthetwoendpointsoftheline,savetheleftendpointin(x0,y0)
Plotthepoint(x0 ,y0)
CalculatetheconstantsΔx,Δy,2Δy,and(2Δy -2Δx)andobtainthefirstvalueforthe
decisionparameteras:
p0 =2Δy-Δx
Performthefollowingtestateachxk alongtheline,beginningatk=0.If pk <0,thenthe
nextpointtotheplotis(xk+1 , yk)and:
pk+1 =pk +2Δy
Otherwise,thenextpointtoplotis(xk+1 ,yk+1)and:
pk+1 =pk +2Δy-2Δx
 Repeatstep4,(Δx –1) times
Thestep-wise Bresenham’s linedrawingalgorithmisgivenbelow:
PARALLEL LINE ALGORITHM:
Aparallel algorithm,as opposed toatraditional serial algorithm,isan
algorithmwhichcandomultipleoperations inagiventime. Ithasbeena
traditionof computer sciencetodescribeserial algorithms inabstract
machinemodels, often the oneknown asrandom-access machine.
Theprocessing sothatpixel positions canbecalculatedefficiently in
parallel.
 Foralinewithslope 0<m<1andleft endpointcoordinate
position (x0,y0),Thedistancebetween beginningxpositions of
adjacentpartitionscanbecalculatedas:
∆xp=(∆xnp-1)/np
 Where ∆xisthewidthofthe line,andthevalue forpartition
width ∆xpiscomputed using integer division.
xk=x0 k∆xp
 Thechange∆yp,intheydirectionover eachpartitionis
calculatedfromthelineslope mandpartitionwidth ∆xp:
∆yp=m∆xp
 Atthekthpartition,the startingycoordinateisthen
yk=y0 round(k∆yp)
 Theinitialdecisionparameterfor Bresenham’s algorithmat the
startof thekthsubintervalis obtainedfrom
pk=(k∆xp)(2∆y)-round(k∆yp)(2∆x) 2∆y-∆x
 Examples ofParallel Algorithms:
Primes.
Sparse MatrixMultiplication.
PlanarConvex-Hull.
ThreeOther Algorithms.
 Twolines areparallellines ifthey donotintersect. Theslopes ofthe lines
arethesame. f(x)=m1x+b1 andg(x)=m2x+b2 areparallel ifm1=m2f( x)=m1
x+b1andg(x)=m2x+b2 areparallelifm1=m2. I
 Analgorithmisasequenceof steps thattakeinputsfromthe user
andaftersomecomputation,producesanoutput.
 Aparallelalgorithmisanalgorithmthatcanexecute several
instructionssimultaneously ondifferent processing devices andthen
combinealltheindividualoutputsto producethefinalresult.
 Calculate pixelpositions alongalinepathsimultaneously by
partitioningthecomputationsamongthevarious processors
available.
THANKS YOU!!!

More Related Content

Similar to OUTPUT PRIMITIVES.pptx

Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
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
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptxAhmadAbba6
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solvedKuntal Bhowmick
 
Equations of graphs
Equations of graphsEquations of graphs
Equations of graphsPalash Dey
 
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
 
February 18 2016
February 18 2016February 18 2016
February 18 2016khyps13
 
5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!A Jorge Garcia
 
scan conversion of point , line and circle
scan conversion of point , line and circlescan conversion of point , line and circle
scan conversion of point , line and circleDivy Kumar Gupta
 
elementry-objects-CG give great effort on learning for exam
elementry-objects-CG give great effort on learning for examelementry-objects-CG give great effort on learning for exam
elementry-objects-CG give great effort on learning for examtigag49721
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
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
 

Similar to OUTPUT PRIMITIVES.pptx (20)

Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Dda algo notes
Dda algo notesDda algo notes
Dda algo notes
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
 
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
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
 
Equations of graphs
Equations of graphsEquations of graphs
Equations of graphs
 
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
 
February 18 2016
February 18 2016February 18 2016
February 18 2016
 
5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!
 
scan conversion of point , line and circle
scan conversion of point , line and circlescan conversion of point , line and circle
scan conversion of point , line and circle
 
elementry-objects-CG give great effort on learning for exam
elementry-objects-CG give great effort on learning for examelementry-objects-CG give great effort on learning for exam
elementry-objects-CG give great effort on learning for exam
 
Calc 7.1a
Calc 7.1aCalc 7.1a
Calc 7.1a
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
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
 

Recently uploaded

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Recently uploaded (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

OUTPUT PRIMITIVES.pptx

  • 2. POINTS AND LINES: A line connects two points. It is a basic element in graphics. To draw a line, you need two points between which youcandraw aline. In the following three algorithms, we refer the one point of line as X0,Y0 and the second point of lineasX1,Y1.
  • 4. Pointsisthefundamentalelementof picturerepresentation. Two points represent line or edge and 3 or more points a polygon. Curvedlinesarerepresentedbytheshort straightlines. It is the position in the plan defined as either pair or triplets of numberdependinguponthedimension.
  • 5. LINE-DRAWING ALGORITHMS: The process of ”turing on” the pixels for a line segment is called vector generation or line generation,and the algorithms for them are known as vector generation algorithmsorlinedrawingalgorithms. Before discussing specific line drawing algorithms it is useful to note the general requirements for such algorithms.
  • 6. The cartesian slope-intercept equation for a straight line is y=m.x+b Slopeofthelinem= y2-y1/x2-x1 Interceptbwith b=y1-m.x1
  • 7.  The line should appears as a straight line and it shouldstartandendaccurately.  The line should be displayed with constant brightness alongit  lengthandorientation.  Thelineshouldbedrawnrapidly Theserequirementspecifythedesiredcharacteristicsofline:
  • 8.
  • 9.  Input: At least one or more inputs must be accept a good algorithm.  Output:Atleastoneoutputmustproducedanalgorithm.  An algorithm should be precise: The algorithm’s each step mustwell-define.  Finiteness: Finiteness is require in an algorithm. It signifies that the algorithm will come to a halt once all of the steps havebeencomplete. PropertiesofaLineDrawing Algorithm:
  • 10.  Correctness: An algorithm must implemented correctly.  Uniqueness: The result of an algorithm should be basedonthe given input, andall stepsof the algorithm shouldbeclearlyanduniquelydefined.  Effectiveness: An algorithm’s steps must be correct andefficient.  Easy to understand: Learners must be able to understand the solution in a more natural way thanks toanalgorithm.
  • 11. DDA ALGORITHM: The digital differential analyser(DDA) is a scan- conversion line algorithm based on calculating either ∆yor ∆x. A linear DDA starts by calculating the smaller of dy or dxforaunitincrementof theother. It is a simple and efficient algorithm that works by using the incremental difference between the x- coordinates and y-coordinates of the two endpoints toplot theline.
  • 12.  Thetwo endpointsof thelinesegment, (x1,y1) and(x2,y2).  Calculate thedifference between thex-coordinates andy- coordinates oftheendpoints asdxand dyrespectively.  Calculate theslope ofthe lineasm= dy/dx.  Set theinitialpointofthelineas(x1,y1).  Loopthroughthe x-coordinates of theline,incrementingbyone eachtime, andcalculatethecorresponding y-coordinateusing theequationy=y1+m(x –x1).  Plot thepixelatthecalculated(x,y) coordinate.  Repeat steps 5and6untiltheendpoint(x2,y2) isreached. Asteps involved inDDAlinegenerationalgorithmare:
  • 13.
  • 14.  Sample at unit x intervals(∆x = 1) and compute each successive y valueas yk+1 =yk +m.  Sample at unit y intervals(∆y = 1) and compute each succeeding x valueas xk+1 =xk + 1/m.  If this processing is reversed,so that the starting ebdpoint is at right,then either∆x=-1  If absolute value of the slope is less than 1 and the start endpoint is at theleft, ∆x=1
  • 15. The digital differential analyser(DDA) is a scan-conversion line algorithm based oncalculatingeither∆yor ∆x. A linear DDA starts by calculating the smaller of dy or dx for a unit incrementof the other. It is a simple and efficient algorithm that works by using the incremental difference between the x-coordinates and y-coordinates of the two endpoints to plotthe line.
  • 16. BRESENHAM’S LINE ALGORITHM: The main task is to find all the intermediate points required fordrawinglineABonthecomputerscreen of pixels. In this algorithm, every pixel has integer coordinates. Apart from that, the Bresenham algorithm works on addition and subtractionoperations. This algorithmis usedforscanconvertingaline.
  • 17. It’s a line drawing algorithm that determines the points of an n-dimensional raster that should be selected in order to form a close approximation to a straight line between two points. Bresenham's algorithm - a fundamental method in Computer Graphics - is a clever way of approximating a continuous straight line with discrete pixels, ensuring that the line appears straight and smooth on a pixel- based display.
  • 18. Points meant by group of pixels.
  • 19. So, d_upperandd_lower aregivenasfollows: d_lower =y-yk =m*(xk+1)+ b-yk d_upper=(yk + 1)-y =yk + 1-m*(xk +1) -b  Slope formula:y=m(xk +1)+b
  • 20.  Thedifference between two-pixel places served thebasis forthis straightforward decision: d_lower -d_upper=2m(xk +1) - 2yk +2b -1  Let’ssubstitute mwith ∆y/∆xwhere ∆xand∆yarethedifferences between theendpoints: ∆x(d_lower -d_upper)=∆x( (2∆y/∆x)(xk +1)-2yk) +(2b -1) =2∆y.xk -2∆x.yk +2∆y +∆x(2b -1) =2∆y.xk -2∆x.yk + c  So, atthekthstep alongaline, adecisionparameterpk isgivenby: pk=∆x(d_upper-d_lower) =2∆y.xk -2∆x.yk +c
  • 21.  Thevalues ofsuccessive decisionparameters using incremental integercalculation.Atstep k+1, the decision parameterisevaluated from as: pk+1=2∆y.(xk+1) -2∆x.(yk+1) + c  From thepreceding equation: pk+1 -pk =2∆y.(xk+1 - xk) -2∆x (yk+1 -yk)  But xk+1= xk +1 pk+1 =pk +2∆y -2∆x(yk+1 -yk)
  • 22. Whereyk+1-yk iseither 0or1dependingonthe signofpk Theinitialdecisionparameterp0 isevaluated at (x0,y0)andiswritten asfollows: p0 =2∆y-∆x  Bresenham Line drawing algorithm is used for scan converting a line. It is an efficient method because it involves integer addition, subtraction, and multiplication operations. Because these actions may be completed quickly, linescanbegenerated quickly.
  • 23. Inputthetwoendpointsoftheline,savetheleftendpointin(x0,y0) Plotthepoint(x0 ,y0) CalculatetheconstantsΔx,Δy,2Δy,and(2Δy -2Δx)andobtainthefirstvalueforthe decisionparameteras: p0 =2Δy-Δx Performthefollowingtestateachxk alongtheline,beginningatk=0.If pk <0,thenthe nextpointtotheplotis(xk+1 , yk)and: pk+1 =pk +2Δy Otherwise,thenextpointtoplotis(xk+1 ,yk+1)and: pk+1 =pk +2Δy-2Δx  Repeatstep4,(Δx –1) times Thestep-wise Bresenham’s linedrawingalgorithmisgivenbelow:
  • 24. PARALLEL LINE ALGORITHM: Aparallel algorithm,as opposed toatraditional serial algorithm,isan algorithmwhichcandomultipleoperations inagiventime. Ithasbeena traditionof computer sciencetodescribeserial algorithms inabstract machinemodels, often the oneknown asrandom-access machine. Theprocessing sothatpixel positions canbecalculatedefficiently in parallel.
  • 25.
  • 26.  Foralinewithslope 0<m<1andleft endpointcoordinate position (x0,y0),Thedistancebetween beginningxpositions of adjacentpartitionscanbecalculatedas: ∆xp=(∆xnp-1)/np  Where ∆xisthewidthofthe line,andthevalue forpartition width ∆xpiscomputed using integer division. xk=x0 k∆xp
  • 27.  Thechange∆yp,intheydirectionover eachpartitionis calculatedfromthelineslope mandpartitionwidth ∆xp: ∆yp=m∆xp  Atthekthpartition,the startingycoordinateisthen yk=y0 round(k∆yp)  Theinitialdecisionparameterfor Bresenham’s algorithmat the startof thekthsubintervalis obtainedfrom pk=(k∆xp)(2∆y)-round(k∆yp)(2∆x) 2∆y-∆x
  • 28.
  • 29.  Examples ofParallel Algorithms: Primes. Sparse MatrixMultiplication. PlanarConvex-Hull. ThreeOther Algorithms.  Twolines areparallellines ifthey donotintersect. Theslopes ofthe lines arethesame. f(x)=m1x+b1 andg(x)=m2x+b2 areparallel ifm1=m2f( x)=m1 x+b1andg(x)=m2x+b2 areparallelifm1=m2. I
  • 30.  Analgorithmisasequenceof steps thattakeinputsfromthe user andaftersomecomputation,producesanoutput.  Aparallelalgorithmisanalgorithmthatcanexecute several instructionssimultaneously ondifferent processing devices andthen combinealltheindividualoutputsto producethefinalresult.  Calculate pixelpositions alongalinepathsimultaneously by partitioningthecomputationsamongthevarious processors available.