SlideShare a Scribd company logo
1. Line Drawing Algorithms
Straight line drawing algorithms are based on incremental methods.
In incremental method line starts with a straight point, then some fix
incrementable is added to current point to get next point on line and same is
continued all the end of line.
1
Simple DDAAlgorithm
Step 1: Read the end points of line.
Step 2: x =abs (x2-x1) and
 y=abs (y2-y1)
Step 3: if x ≥ v then
length = x
else
length = y
end if
Step 4: x line = (x2-x1) / length
Step 5: y line = (y2-y1) / length
Step 6: x=x1+0.5*sign (x line)
y=y1+0.5*sign (y line)
Step 7: i=1
while (i ≤length)
{ plot (integer (x), integer (y))
x= x + x line
y= y + y line
i=i+1
}
Step 8: End
2
Simple DDAAlgorithm (Example)
Q: (First Quadrant Example)
Consider a line from (0,0) to (5,6). Use simple DDA
algorithm to rasterize this line.
Solutions: it is a line in first quadrant.
Now follow algorithm step-by-step.
Step 1: Read end points of line
(x1,y1) = (0,0) and
(x2,y2) = (5,6)
Step 2: x=abs (x2-x1)
x=abs(5-0)
x=5
y=abs(y2-ya)
y=abs(6-0)
y=6
Step 3: As (6>5)
length=6
Step 4: x line = 5/6
x=0.833
y=6/6
y=1
Step 5: x=x1+0.5*sign(x line)
x=0+0.5*sign(0.8333)
x=0+0.5*1
x=0.5
Step 6: y=y1+0.5*sign(y line)
y=0+0.5*sign(1)
y=0+0.5*1
y=0.5
Step 7: End
3
1. Line Drawing Algorithms
Value of 1 Plot
Pixel
x y
0.5 0.5
1 (0,0)
1.333 1.5
2 (1,1)
2.166 2.5
3 (2,2)
2.999 3.5
4 (2,3)
3.832 4.5
5 (3,4)
4.665 5.5
6 (4,5)
5.498 6.5
0 1 2 3 4 5
012345
(0,0)
4
Demerits of DDAAlgorithm
1. Floating points arithmetic in DDA algorithm is time consuming.
2. Accumulation of round-off error in successive additions of floating
point increment can cause the calculated pixel positions to drift away
from the true line path for long line segments.
Merits of DDAAlgorithm
1. It is simple algorithm.
2. It is faster method.
Let’s see example problems to illustrate simple DDAAlgorithm.
5
Bresnahan's line drawing
The process of "turning on" the pixels for a line is called the generation.
A line that means we have to change the intensity of the pixels present on
that line.
In this we have two different algorithm.
yk + 1
y
yk
xk + 1
d2
d1
6
Bresnahan's line drawing algorithm
Step 1: Read line end points as (x1-x1) and (x2-y2)
Step 2: x=|x2=x1| and y=|y2-y1|
Step 3: Initialize starting point of line
i.e. x=x1
y=y1
Step 4: Plot (x,y) i.e. plot first point
Step 5: obtain initial value of decision parameter Pk
as
Pk=2 y- x
Step 6: if Pk,0
{
x=x+1
y=y+1
Pk=Pk+2 y
}
if Pk ≥ 0
{
x=x+1
y=y+1
Pk=Pk+2y=2x
}
plot (x,y)
Step 7: Repeat step (6) x times.
Step 8: Stop
7
Bresnahan's line drawing Example
Q: Consider the line from (6,6) to (12,9)
Use Brissenden's algorithm to rasterize this line.
Solutions: Following algorithm 3 step-by-step
Step 1: x1=6
y1=6
x2=12
y2=9
Step 2: x=|12-6|=6
t=|12-9|=3
Step 3: x=6
y=6
Step 4: Plot (x,y) i..e Plot (6,6), initial point
Step 5: value of decision parameter,
Pk=2 y- x
Pk=2(3)-6
Pk=0
Step 6 and 7: Now i=1 . See Table
Step 8: Stop
i Plot
Pixel
X Y Pk
6 6 0
1 (6,6) 7 7 -6
2 (7,7) 8 7 0
3 (8,7) 9 8 -6
4 (9,8) 10 8 0
5 (10,8) 11 9 -6
6 (11,9) 12 9 0
Output:
Step 6 and 7
10
11
9
8
6
7
4
5
10 11986 74 5
8
DDA VS Bresnahan's (Different)
SR DDA Bresnahan's
1 Based on increment method. Based on increment
method.
2 Use floating point arithmetic. Use only integers.
3 Slower then Bresnahan's Faster than DDA.
4 Use of multiplication and
division operations.
Use of only Addition
and Subtraction
operations.
5 To display pixel we need to use
either floor or ceil function.
No need of floor or
ceil function for
display.
6 Because of floor and ceil
function error component is
introduced.
No error component
is introduced.
7 The co-ordinate location is same
as that of Bresnahan's.
The co-ordinate
location same as that
DDA 9
Circle Generating Algorithms
-x, y
-x, -y
-y, -x y, -x
x, -y
x, y
y, x-y, x
45
Symmetry of Circle
10
Bresnahan’s circle Generating Algorithm
Step 1: Read radius (r) of circle.
Step 2: Calculate initial decision variable Pi
Step 3: x=0 and y=r
Step 4: if (Pi,0)
{
x=x+1
Pi=Pi+4x+6
}
else if (Pi≥ 0)
{
x=x+1
y=y-1
Pi=Pi+4(x-y)+10
}
Step 5: Plot pixels in all octants as
Plot (x,y)
Plot(y,x)
Plot(-y,x)
Plot(-x,y)
Plot(-x,-y)
Plot(y,-x)
Plot(x,-y)
Step 6: Stop
11
Mid-point Circle Generating Algorithms
Step 1: Read radius (r) of circle.
Step 2: obtain first point on circle boundary as
(x0,y0)=(0,r)
Step 3: Calculate initial decision parameter as
P0=1-r
Step 4: if (Pi,0)
{
xi=xi+1
yi=yi
Pi+1=Pi+2(xi+1)+1
}
else if(Pi.0)
{
xi=xi+1
yi=yi-1
Pi+1=Pi+2(xi+1)+1-2yi+1
}
Step 5: Plot pixels in all octants as
Plot (y,x)
Plot(-y,x)
Plot(-x,y)
Plot(-x,-y)
Plot(-y,-x)
Plot(y,-x)
Plot(x,-y)
Step 6: Repeat step 4 and 5 until xi≥ yi
Step 7: Stop
12
Mid-point Circle Generating Example
Q : Given radius of circle r=8 with center at origin.
Solution : Here origin is center of circle and we
will demonstrate algorithm execution for
determining points along circle boundary only in
first quadrant from x=0 and x=y
Now, following are the seps of algorithm.
Step 1: r=8
Step 2: (x0,y0)=(0,8)
Step 3: P0=1-r
P0=1-8=-7
Step 4: Following table shows iterative execution
of this step to calculate each next x0i,yi(i.e. xi+1,
yi+1) till xi ≥yi
Step 5: for each value of I in step 4 plot
(xi+1,yi+1) and also plot all symmetric points in all
rest octants.
Step 6: Note, Actually step 4 and 5 are executed in
iteration for each value of I step 4 followed by step
5 is executed.
Step 7: Stop
i Pi (xi+1,yi+1) Pi+1 if
(Pi<0)
Pi+1 if
(Pi>0)
0 -7 (1,7) -3 -
1 -3 (2,7) +2 -
2 2 (3,6) - -3
3 -3 (4,6) 6 -
4 6 (5,5) - 7
13
Character Generation Method
1. Stroke method/vector character generation method
14
Character Generation Method
2. Dot-matrix or Bit-map method
1 2 3 4 5 1
2
3
4
5
6
7
8
9
2
3
4
5
6
1
7
1 2 3 4 5 6 7
Height
Height
Width
Width
15
Character Generation Method
3. Starbust method
1
2
3 4
14 5
62221
17 18
2313
12
11
10 9
8
7
1524
19
16
20
43
2
1
10 9
12
11
21
Starbust pattern of 24 line segments Starbust pattern for character E
24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
Bit number
16

More Related Content

What's hot

Character generation techniques
Character generation techniquesCharacter generation techniques
Character generation techniques
Mani Kanth
 
DDA algorithm
DDA algorithmDDA algorithm
DDA algorithm
Yash Patel
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
SHIVANI SONI
 
Composite transformations
Composite transformationsComposite transformations
Composite transformationsMohd Arif
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displays
Somya Bagai
 
Data link layer
Data link layer Data link layer
Data link layer
Mukesh Chinta
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
2013901097
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
Ankit Garg
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
Timbal Mayank
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
Aparna Joshi
 
3 d display methods
3 d display methods3 d display methods
3 d display methods
Shami Al Rahad
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
smruti sarangi
 
Anti- aliasing computer graphics
Anti- aliasing computer graphicsAnti- aliasing computer graphics
Anti- aliasing computer graphics
Safayet Hossain
 
Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...
Mani Kanth
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in Graphics
Rajani Thite
 
03.Scan Conversion.ppt
03.Scan Conversion.ppt03.Scan Conversion.ppt
03.Scan Conversion.ppt
RobinAhmedSaikat
 
Z buffer
Z bufferZ buffer
Z buffer
AmitBiswas99
 
Back face detection
Back face detectionBack face detection
Back face detection
Pooja Dixit
 

What's hot (20)

Character generation techniques
Character generation techniquesCharacter generation techniques
Character generation techniques
 
DDA algorithm
DDA algorithmDDA algorithm
DDA algorithm
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 
Bresenham circle
Bresenham circleBresenham circle
Bresenham circle
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displays
 
Data link layer
Data link layer Data link layer
Data link layer
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
3 d display methods
3 d display methods3 d display methods
3 d display methods
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Anti- aliasing computer graphics
Anti- aliasing computer graphicsAnti- aliasing computer graphics
Anti- aliasing computer graphics
 
Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in Graphics
 
Np cooks theorem
Np cooks theoremNp cooks theorem
Np cooks theorem
 
03.Scan Conversion.ppt
03.Scan Conversion.ppt03.Scan Conversion.ppt
03.Scan Conversion.ppt
 
Z buffer
Z bufferZ buffer
Z buffer
 
Back face detection
Back face detectionBack face detection
Back face detection
 

Similar to Line Drawing Algorithms - Computer Graphics - Notes

Study on Fundamentals of Raster Scan Graphics
Study on Fundamentals of Raster Scan GraphicsStudy on Fundamentals of Raster Scan Graphics
Study on Fundamentals of Raster Scan Graphics
Chandrakant Divate
 
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
Amol Gaikwad
 
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
ssuser255bf1
 
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
Vishal Butkar
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
SanthiNivas
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
Mattupallipardhu
 
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 derication
Kumar
 
Cs580
Cs580Cs580
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
Prabin Gautam
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
Kokebe2
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
Ankit Garg
 
Open GL T0074 56 sm2
Open GL T0074 56 sm2Open GL T0074 56 sm2
Open GL T0074 56 sm2Roziq Bahtiar
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
KimTaehyung188352
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsThirunavukarasu Mani
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 
Unit 2
Unit 2Unit 2
Unit 2
ypnrao
 
Unit 3
Unit 3Unit 3
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
aravindangc
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 

Similar to Line Drawing Algorithms - Computer Graphics - Notes (20)

Study on Fundamentals of Raster Scan Graphics
Study on Fundamentals of Raster Scan GraphicsStudy on Fundamentals of Raster Scan Graphics
Study on Fundamentals of Raster Scan Graphics
 
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
 
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
 
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 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.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
 
Cs580
Cs580Cs580
Cs580
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
Open GL T0074 56 sm2
Open GL T0074 56 sm2Open GL T0074 56 sm2
Open GL T0074 56 sm2
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unit 3
Unit 3Unit 3
Unit 3
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 

More from Omprakash Chauhan

Introduction to curve
Introduction to curveIntroduction to curve
Introduction to curve
Omprakash Chauhan
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - Notes
Omprakash Chauhan
 
Sorting and Searching - Data Structure - Notes
Sorting and Searching - Data Structure - NotesSorting and Searching - Data Structure - Notes
Sorting and Searching - Data Structure - Notes
Omprakash Chauhan
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
Omprakash Chauhan
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - Notes
Omprakash Chauhan
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - Notes
Omprakash Chauhan
 
Basic of computer graphic - Computer Graphic - Notes
Basic of computer graphic - Computer Graphic - NotesBasic of computer graphic - Computer Graphic - Notes
Basic of computer graphic - Computer Graphic - Notes
Omprakash Chauhan
 
E-R Diagram of College Management Systems
E-R Diagram of College Management SystemsE-R Diagram of College Management Systems
E-R Diagram of College Management Systems
Omprakash Chauhan
 
Burglar Alarm Micro Project
Burglar Alarm Micro ProjectBurglar Alarm Micro Project
Burglar Alarm Micro Project
Omprakash Chauhan
 
Simple Calculator Flowchart
Simple Calculator FlowchartSimple Calculator Flowchart
Simple Calculator Flowchart
Omprakash Chauhan
 
Full Wave Rectifier (FWR) Microproject
Full Wave Rectifier (FWR) MicroprojectFull Wave Rectifier (FWR) Microproject
Full Wave Rectifier (FWR) Microproject
Omprakash Chauhan
 
A detailed study of guidelines required for presentation skills
A detailed study of guidelines required for presentation skillsA detailed study of guidelines required for presentation skills
A detailed study of guidelines required for presentation skills
Omprakash Chauhan
 
Fractional-horsepower Motor Report
Fractional-horsepower Motor ReportFractional-horsepower Motor Report
Fractional-horsepower Motor Report
Omprakash Chauhan
 
motherboard electronic components and their functions
motherboard electronic components and their functionsmotherboard electronic components and their functions
motherboard electronic components and their functions
Omprakash Chauhan
 
How To Area of irregular shape Using Integration Method.
How To Area of irregular shape Using Integration Method.How To Area of irregular shape Using Integration Method.
How To Area of irregular shape Using Integration Method.
Omprakash Chauhan
 
Process of ionization
Process of ionizationProcess of ionization
Process of ionization
Omprakash Chauhan
 
Welcome to the world of ionization
Welcome to the world of ionization Welcome to the world of ionization
Welcome to the world of ionization
Omprakash Chauhan
 
Printer
PrinterPrinter
System of units
System of unitsSystem of units
System of units
Omprakash Chauhan
 

More from Omprakash Chauhan (19)

Introduction to curve
Introduction to curveIntroduction to curve
Introduction to curve
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - Notes
 
Sorting and Searching - Data Structure - Notes
Sorting and Searching - Data Structure - NotesSorting and Searching - Data Structure - Notes
Sorting and Searching - Data Structure - Notes
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - Notes
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - Notes
 
Basic of computer graphic - Computer Graphic - Notes
Basic of computer graphic - Computer Graphic - NotesBasic of computer graphic - Computer Graphic - Notes
Basic of computer graphic - Computer Graphic - Notes
 
E-R Diagram of College Management Systems
E-R Diagram of College Management SystemsE-R Diagram of College Management Systems
E-R Diagram of College Management Systems
 
Burglar Alarm Micro Project
Burglar Alarm Micro ProjectBurglar Alarm Micro Project
Burglar Alarm Micro Project
 
Simple Calculator Flowchart
Simple Calculator FlowchartSimple Calculator Flowchart
Simple Calculator Flowchart
 
Full Wave Rectifier (FWR) Microproject
Full Wave Rectifier (FWR) MicroprojectFull Wave Rectifier (FWR) Microproject
Full Wave Rectifier (FWR) Microproject
 
A detailed study of guidelines required for presentation skills
A detailed study of guidelines required for presentation skillsA detailed study of guidelines required for presentation skills
A detailed study of guidelines required for presentation skills
 
Fractional-horsepower Motor Report
Fractional-horsepower Motor ReportFractional-horsepower Motor Report
Fractional-horsepower Motor Report
 
motherboard electronic components and their functions
motherboard electronic components and their functionsmotherboard electronic components and their functions
motherboard electronic components and their functions
 
How To Area of irregular shape Using Integration Method.
How To Area of irregular shape Using Integration Method.How To Area of irregular shape Using Integration Method.
How To Area of irregular shape Using Integration Method.
 
Process of ionization
Process of ionizationProcess of ionization
Process of ionization
 
Welcome to the world of ionization
Welcome to the world of ionization Welcome to the world of ionization
Welcome to the world of ionization
 
Printer
PrinterPrinter
Printer
 
System of units
System of unitsSystem of units
System of units
 

Recently uploaded

ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 

Recently uploaded (20)

ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 

Line Drawing Algorithms - Computer Graphics - Notes

  • 1. 1. Line Drawing Algorithms Straight line drawing algorithms are based on incremental methods. In incremental method line starts with a straight point, then some fix incrementable is added to current point to get next point on line and same is continued all the end of line. 1
  • 2. Simple DDAAlgorithm Step 1: Read the end points of line. Step 2: x =abs (x2-x1) and  y=abs (y2-y1) Step 3: if x ≥ v then length = x else length = y end if Step 4: x line = (x2-x1) / length Step 5: y line = (y2-y1) / length Step 6: x=x1+0.5*sign (x line) y=y1+0.5*sign (y line) Step 7: i=1 while (i ≤length) { plot (integer (x), integer (y)) x= x + x line y= y + y line i=i+1 } Step 8: End 2
  • 3. Simple DDAAlgorithm (Example) Q: (First Quadrant Example) Consider a line from (0,0) to (5,6). Use simple DDA algorithm to rasterize this line. Solutions: it is a line in first quadrant. Now follow algorithm step-by-step. Step 1: Read end points of line (x1,y1) = (0,0) and (x2,y2) = (5,6) Step 2: x=abs (x2-x1) x=abs(5-0) x=5 y=abs(y2-ya) y=abs(6-0) y=6 Step 3: As (6>5) length=6 Step 4: x line = 5/6 x=0.833 y=6/6 y=1 Step 5: x=x1+0.5*sign(x line) x=0+0.5*sign(0.8333) x=0+0.5*1 x=0.5 Step 6: y=y1+0.5*sign(y line) y=0+0.5*sign(1) y=0+0.5*1 y=0.5 Step 7: End 3
  • 4. 1. Line Drawing Algorithms Value of 1 Plot Pixel x y 0.5 0.5 1 (0,0) 1.333 1.5 2 (1,1) 2.166 2.5 3 (2,2) 2.999 3.5 4 (2,3) 3.832 4.5 5 (3,4) 4.665 5.5 6 (4,5) 5.498 6.5 0 1 2 3 4 5 012345 (0,0) 4
  • 5. Demerits of DDAAlgorithm 1. Floating points arithmetic in DDA algorithm is time consuming. 2. Accumulation of round-off error in successive additions of floating point increment can cause the calculated pixel positions to drift away from the true line path for long line segments. Merits of DDAAlgorithm 1. It is simple algorithm. 2. It is faster method. Let’s see example problems to illustrate simple DDAAlgorithm. 5
  • 6. Bresnahan's line drawing The process of "turning on" the pixels for a line is called the generation. A line that means we have to change the intensity of the pixels present on that line. In this we have two different algorithm. yk + 1 y yk xk + 1 d2 d1 6
  • 7. Bresnahan's line drawing algorithm Step 1: Read line end points as (x1-x1) and (x2-y2) Step 2: x=|x2=x1| and y=|y2-y1| Step 3: Initialize starting point of line i.e. x=x1 y=y1 Step 4: Plot (x,y) i.e. plot first point Step 5: obtain initial value of decision parameter Pk as Pk=2 y- x Step 6: if Pk,0 { x=x+1 y=y+1 Pk=Pk+2 y } if Pk ≥ 0 { x=x+1 y=y+1 Pk=Pk+2y=2x } plot (x,y) Step 7: Repeat step (6) x times. Step 8: Stop 7
  • 8. Bresnahan's line drawing Example Q: Consider the line from (6,6) to (12,9) Use Brissenden's algorithm to rasterize this line. Solutions: Following algorithm 3 step-by-step Step 1: x1=6 y1=6 x2=12 y2=9 Step 2: x=|12-6|=6 t=|12-9|=3 Step 3: x=6 y=6 Step 4: Plot (x,y) i..e Plot (6,6), initial point Step 5: value of decision parameter, Pk=2 y- x Pk=2(3)-6 Pk=0 Step 6 and 7: Now i=1 . See Table Step 8: Stop i Plot Pixel X Y Pk 6 6 0 1 (6,6) 7 7 -6 2 (7,7) 8 7 0 3 (8,7) 9 8 -6 4 (9,8) 10 8 0 5 (10,8) 11 9 -6 6 (11,9) 12 9 0 Output: Step 6 and 7 10 11 9 8 6 7 4 5 10 11986 74 5 8
  • 9. DDA VS Bresnahan's (Different) SR DDA Bresnahan's 1 Based on increment method. Based on increment method. 2 Use floating point arithmetic. Use only integers. 3 Slower then Bresnahan's Faster than DDA. 4 Use of multiplication and division operations. Use of only Addition and Subtraction operations. 5 To display pixel we need to use either floor or ceil function. No need of floor or ceil function for display. 6 Because of floor and ceil function error component is introduced. No error component is introduced. 7 The co-ordinate location is same as that of Bresnahan's. The co-ordinate location same as that DDA 9
  • 10. Circle Generating Algorithms -x, y -x, -y -y, -x y, -x x, -y x, y y, x-y, x 45 Symmetry of Circle 10
  • 11. Bresnahan’s circle Generating Algorithm Step 1: Read radius (r) of circle. Step 2: Calculate initial decision variable Pi Step 3: x=0 and y=r Step 4: if (Pi,0) { x=x+1 Pi=Pi+4x+6 } else if (Pi≥ 0) { x=x+1 y=y-1 Pi=Pi+4(x-y)+10 } Step 5: Plot pixels in all octants as Plot (x,y) Plot(y,x) Plot(-y,x) Plot(-x,y) Plot(-x,-y) Plot(y,-x) Plot(x,-y) Step 6: Stop 11
  • 12. Mid-point Circle Generating Algorithms Step 1: Read radius (r) of circle. Step 2: obtain first point on circle boundary as (x0,y0)=(0,r) Step 3: Calculate initial decision parameter as P0=1-r Step 4: if (Pi,0) { xi=xi+1 yi=yi Pi+1=Pi+2(xi+1)+1 } else if(Pi.0) { xi=xi+1 yi=yi-1 Pi+1=Pi+2(xi+1)+1-2yi+1 } Step 5: Plot pixels in all octants as Plot (y,x) Plot(-y,x) Plot(-x,y) Plot(-x,-y) Plot(-y,-x) Plot(y,-x) Plot(x,-y) Step 6: Repeat step 4 and 5 until xi≥ yi Step 7: Stop 12
  • 13. Mid-point Circle Generating Example Q : Given radius of circle r=8 with center at origin. Solution : Here origin is center of circle and we will demonstrate algorithm execution for determining points along circle boundary only in first quadrant from x=0 and x=y Now, following are the seps of algorithm. Step 1: r=8 Step 2: (x0,y0)=(0,8) Step 3: P0=1-r P0=1-8=-7 Step 4: Following table shows iterative execution of this step to calculate each next x0i,yi(i.e. xi+1, yi+1) till xi ≥yi Step 5: for each value of I in step 4 plot (xi+1,yi+1) and also plot all symmetric points in all rest octants. Step 6: Note, Actually step 4 and 5 are executed in iteration for each value of I step 4 followed by step 5 is executed. Step 7: Stop i Pi (xi+1,yi+1) Pi+1 if (Pi<0) Pi+1 if (Pi>0) 0 -7 (1,7) -3 - 1 -3 (2,7) +2 - 2 2 (3,6) - -3 3 -3 (4,6) 6 - 4 6 (5,5) - 7 13
  • 14. Character Generation Method 1. Stroke method/vector character generation method 14
  • 15. Character Generation Method 2. Dot-matrix or Bit-map method 1 2 3 4 5 1 2 3 4 5 6 7 8 9 2 3 4 5 6 1 7 1 2 3 4 5 6 7 Height Height Width Width 15
  • 16. Character Generation Method 3. Starbust method 1 2 3 4 14 5 62221 17 18 2313 12 11 10 9 8 7 1524 19 16 20 43 2 1 10 9 12 11 21 Starbust pattern of 24 line segments Starbust pattern for character E 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 Bit number 16