SlideShare a Scribd company logo
6
Case 1: If E is chosen (d<0)
dnew= F(xp +2, yp+1/2)
= a(xp +2) + b(yp+1/2) +c
dold = a(xp+1) + b(yp+1/2)+c
∆d = dnew -dold
= a(xp +2)- a(xp+1)+ b(yp+1/2)- b(yp+1/2)+c-c
= a(xp) +2a –a(xp) –a = a.
Therefore, dnew = dold + dy
Case 2: If NE is chosen (d>0)
dnew= F(xp +2, yp+3/2)
= a(xp +2) + b(yp+3/2) +c
dold = a(xp+1) + b(yp+1/2)+c
∆d = dnew -dold
= a(xp +2)- a(xp+1)+ b(yp+3/2)- b(yp+1/2)+c-c
= a(xp) +2a –a(xp) –a+ b(yp) +3/2b –
b(yp) -1/2b
= a+b
Therefore, dnew = dold + dy-dx
Most read
10
EXAMPLE Draw a line from (4,8) to (9,12)
and plot the points accordingly.
Initially:
(x,y)=(4,8)
(x1,y1)=(9,12)
dy=(y1-y0)= (12-8)= 4
dx= (x1-x0)=(9-4)= 5
Now, the first decision variable
(d0)= dy- dx/2
= 4-5/2
= 1.5
As d0 >0 , NE is chosen and the next pixel to be plotted will be
( x+1,y+1) i.e. (5,9)
-> d1= d0+ (dy-dx)
= 1.5+ 4-5 = 0.5
As d1 >0 , again NE is chosen and the next pixel to be plotted will be
( x+1,y+1) i.e.(6,10)
Most read
11
-> d2=d1+ dy-dx
= 0.5+4-5 = -0.5
As d2 <0 , E is chosen and the next pixel to be plotted will be
( x+1,y) i.e. (7,10)
-> d3= d2+dy
= -0.5 + 4 = 3.5
As d3 >0 , NE is chosen and the next pixel to be plotted will be ( x+1,y+1)
i.e. (8,11)
-> d4= d3+dy-dx
= 3.5+ 4-5 = 2.5
As d4 >0 , NE is chosen and the next pixel to be plotted will be ( x+1,y+1)
i.e. (9,12)
Now as we have reached our second end point i.e.
(x1,y1)= (9,12) ,we will stop the procedure.
Therefore, the plotted points on the grids will be (5,9) ,(6,10),
( 7,10) ,(8,11) and (9,12).
Most read
MID-POINT LINE
PLOTTING ALGORITHM
MADE BY: DIMPY
CHUGH (1833)
DRISHTI BHALLA (1838)
INTRODUCTION
The Midpoint line algorithm is an incremental line plotting algorithm
i.e. at each step we make incremental calculations based on
preceding step to find next y value, in order to form a close
approximation to a straight line between two points.
 It chooses the pixels closest to the line with accuracy, consistency
and straightness.
 It is very simple and requires only integer data and simple
arithmetic.
 It avoids division and multiplication and thus avoid truncate
errors.
ADVANTAGES
BASISOF ALGORITHM
 Given the previous pixel P, there are two candidates for the next pixel
closest to the line, E and NE .
 If the M is above the line, choose E. If M is below the line, choose NE.
Previous pixel Choices for
current pixel
Previous pixel Choices for
current pixel
Assumptions:
Two end points of a line : (x0, y0) and (x1, y1)
Also, x0 < x1
Since, we are sampling in x-direction, so, for the next pixel , x-coordinate
will be xp+1 i.e. xp+ 1 and correspondingly we will calculate the value of y-
coordinate .
The implicit equation of a line is:
F(x, y) = a x + b y + c …….(1)
dx = x1 –x0
dy = y1 – y0
Slope intercept form a line is : y = m x+ B
y = (dy/dx) x +B
F(x,y)= (x)dy – (y)dx + Bdx ……(2)
Comparing (1) and(2) we get,
a= dy, b= -dx and c= Bdx
DERIVATION
M=(xp +1, yp+1/2)
d= F(M)= F(xp +1, yp+1/2)
- The sign of the decision variable ‘d’ is used to make the midpoint
determination for all remaining pixels.
 If d is negative, the midpoint is above the line and E is chosen
i.e. (xp +1, yp) will be plotted.
 If d is positive, the midpoint is below the line and NE is
chosen, i.e. we will plot (xp +1, yp+1).
As the algorithm progresses from pixel to pixel, d is calculated
with one of two pre-calculated values based on the E/NE decision.
 For all points on the line, the solution to F(x, y) is 0.
 For all points above the line F(x, y) result in a negative number
 For all points below F(x, y) result in a positive number.
This relationship is used to determine the relative position of M.
Case 1: If E is chosen (d<0)
dnew= F(xp +2, yp+1/2)
= a(xp +2) + b(yp+1/2) +c
dold = a(xp+1) + b(yp+1/2)+c
∆d = dnew -dold
= a(xp +2)- a(xp+1)+ b(yp+1/2)- b(yp+1/2)+c-c
= a(xp) +2a –a(xp) –a = a.
Therefore, dnew = dold + dy
Case 2: If NE is chosen (d>0)
dnew= F(xp +2, yp+3/2)
= a(xp +2) + b(yp+3/2) +c
dold = a(xp+1) + b(yp+1/2)+c
∆d = dnew -dold
= a(xp +2)- a(xp+1)+ b(yp+3/2)- b(yp+1/2)+c-c
= a(xp) +2a –a(xp) –a+ b(yp) +3/2b –
b(yp) -1/2b
= a+b
Therefore, dnew = dold + dy-dx
d0= F(x0+1 , y0+1/2)
= a(x0+1) + b(y0+1/2) +c
= ax0+ by0+c +a+ b/2
= F(x0,y0) + a+ b/2
= 0 + a+ b/2 ( a= dy, b= -dx)
Therefore, d0 = dy - dx/2
Derivationforcalculatingthe initial value for d0
ALGORITHM(|M|<1)
1) Input (x0,y0) and (x1,y1)
2) Calculate dy and dx
3) d= dy-(dx/2)
4) x= x0 and y=y0
5) Plot(x , y)
6) While(x<x1)
7) x=x+1
8) If(d<0)
9) d=d+dy
10) else
11) d=d+dy-dx
12) y=y+1
13) Plot(x,y)
ALGORITHM (|M|>1)
1) Input (x0,y0) and (x1,y1)
2) Calculate dy and dx
3) d= dx-(dy/2)
4) x= x0 and y=y0
5) Plot(x , y)
6) While(y<y1)
7) y=y+1
8) If(d<0)
9) d=d+dx
10) else
11) d=d+dx-dy
12) x=x+1
13) Plot(x,y)
EXAMPLE Draw a line from (4,8) to (9,12)
and plot the points accordingly.
Initially:
(x,y)=(4,8)
(x1,y1)=(9,12)
dy=(y1-y0)= (12-8)= 4
dx= (x1-x0)=(9-4)= 5
Now, the first decision variable
(d0)= dy- dx/2
= 4-5/2
= 1.5
As d0 >0 , NE is chosen and the next pixel to be plotted will be
( x+1,y+1) i.e. (5,9)
-> d1= d0+ (dy-dx)
= 1.5+ 4-5 = 0.5
As d1 >0 , again NE is chosen and the next pixel to be plotted will be
( x+1,y+1) i.e.(6,10)
-> d2=d1+ dy-dx
= 0.5+4-5 = -0.5
As d2 <0 , E is chosen and the next pixel to be plotted will be
( x+1,y) i.e. (7,10)
-> d3= d2+dy
= -0.5 + 4 = 3.5
As d3 >0 , NE is chosen and the next pixel to be plotted will be ( x+1,y+1)
i.e. (8,11)
-> d4= d3+dy-dx
= 3.5+ 4-5 = 2.5
As d4 >0 , NE is chosen and the next pixel to be plotted will be ( x+1,y+1)
i.e. (9,12)
Now as we have reached our second end point i.e.
(x1,y1)= (9,12) ,we will stop the procedure.
Therefore, the plotted points on the grids will be (5,9) ,(6,10),
( 7,10) ,(8,11) and (9,12).
THANK YOU!

More Related Content

What's hot (20)

Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
nehrurevathy
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.
Mohd Arif
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
Ankit Garg
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Mohd Arif
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
Kamal Acharya
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
Nanhen Verma
 
2D Transformation in Computer Graphics
2D Transformation in Computer Graphics2D Transformation in Computer Graphics
2D Transformation in Computer Graphics
A. S. M. Shafi
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
Mani Kanth
 
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
 
Unit 3
Unit 3Unit 3
Unit 3
ypnrao
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
Mohanlal Sukhadia University (MLSU)
 
Computer Graphics - Output Primitive
Computer Graphics - Output PrimitiveComputer Graphics - Output Primitive
Computer Graphics - Output Primitive
Rupesh Mishra
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
PrathimaBaliga
 
Anti- aliasing computer graphics
Anti- aliasing computer graphicsAnti- aliasing computer graphics
Anti- aliasing computer graphics
Safayet Hossain
 
2 d viewing computer graphics
2 d viewing computer graphics2 d viewing computer graphics
2 d viewing computer graphics
KALESHWAR KUMAR
 
3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals
Muhammed Afsal Villan
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
Pooja Dixit
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
Mohd Arif
 
COMPOSITE TRANSFORMATION COMPUTER GRAPHICDS.ppt
COMPOSITE TRANSFORMATION COMPUTER GRAPHICDS.pptCOMPOSITE TRANSFORMATION COMPUTER GRAPHICDS.ppt
COMPOSITE TRANSFORMATION COMPUTER GRAPHICDS.ppt
urvashipundir04
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
nehrurevathy
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.
Mohd Arif
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
Ankit Garg
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Mohd Arif
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
Kamal Acharya
 
2D Transformation in Computer Graphics
2D Transformation in Computer Graphics2D Transformation in Computer Graphics
2D Transformation in Computer Graphics
A. S. M. Shafi
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
Mani Kanth
 
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
 
Unit 3
Unit 3Unit 3
Unit 3
ypnrao
 
Computer Graphics - Output Primitive
Computer Graphics - Output PrimitiveComputer Graphics - Output Primitive
Computer Graphics - Output Primitive
Rupesh Mishra
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
PrathimaBaliga
 
Anti- aliasing computer graphics
Anti- aliasing computer graphicsAnti- aliasing computer graphics
Anti- aliasing computer graphics
Safayet Hossain
 
2 d viewing computer graphics
2 d viewing computer graphics2 d viewing computer graphics
2 d viewing computer graphics
KALESHWAR KUMAR
 
3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals3D Graphics : Computer Graphics Fundamentals
3D Graphics : Computer Graphics Fundamentals
Muhammed Afsal Villan
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
Pooja Dixit
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
Mohd Arif
 
COMPOSITE TRANSFORMATION COMPUTER GRAPHICDS.ppt
COMPOSITE TRANSFORMATION COMPUTER GRAPHICDS.pptCOMPOSITE TRANSFORMATION COMPUTER GRAPHICDS.ppt
COMPOSITE TRANSFORMATION COMPUTER GRAPHICDS.ppt
urvashipundir04
 

Similar to Mid point line Algorithm - Computer Graphics (20)

Line circle draw
Line circle drawLine circle draw
Line circle draw
Praveen Kumar
 
99995320.ppt
99995320.ppt99995320.ppt
99995320.ppt
MohdSaqib79
 
computer_graphics_line_algorithm in Computer Graphics
computer_graphics_line_algorithm in Computer Graphicscomputer_graphics_line_algorithm in Computer Graphics
computer_graphics_line_algorithm in Computer Graphics
bsse20142018
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
Mattupallipardhu
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
SanthiNivas
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
Roziq Bahtiar
 
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
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
IndhuMcamphil
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
Alamelu
 
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
Dr. Chandrakant Divate
 
Dda algo notes
Dda algo notesDda algo notes
Dda algo notes
shreeja asopa
 
computer graphic and multimedia for the students of MCA
computer graphic and multimedia for the students of MCAcomputer graphic and multimedia for the students of MCA
computer graphic and multimedia for the students of MCA
RavinderKSingla
 
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohichapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
54MahakBansal
 
Open GL 04 linealgos
Open GL 04 linealgosOpen GL 04 linealgos
Open GL 04 linealgos
Roziq Bahtiar
 
Computer graphics LINE DRAWING algorithm.pptx
Computer graphics LINE DRAWING algorithm.pptxComputer graphics LINE DRAWING algorithm.pptx
Computer graphics LINE DRAWING algorithm.pptx
R S Anu Prabha
 
Computer Graphics_Module 2_Output Primitives.pdf
Computer Graphics_Module 2_Output Primitives.pdfComputer Graphics_Module 2_Output Primitives.pdf
Computer Graphics_Module 2_Output Primitives.pdf
tabbu23
 
Cs580
Cs580Cs580
Cs580
Chellamuthu K
 
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
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
Omprakash Chauhan
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
TutorialsDuniya.com
 
computer_graphics_line_algorithm in Computer Graphics
computer_graphics_line_algorithm in Computer Graphicscomputer_graphics_line_algorithm in Computer Graphics
computer_graphics_line_algorithm in Computer Graphics
bsse20142018
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
SanthiNivas
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
Roziq Bahtiar
 
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
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
IndhuMcamphil
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
Alamelu
 
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
Dr. Chandrakant Divate
 
computer graphic and multimedia for the students of MCA
computer graphic and multimedia for the students of MCAcomputer graphic and multimedia for the students of MCA
computer graphic and multimedia for the students of MCA
RavinderKSingla
 
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohichapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
54MahakBansal
 
Open GL 04 linealgos
Open GL 04 linealgosOpen GL 04 linealgos
Open GL 04 linealgos
Roziq Bahtiar
 
Computer graphics LINE DRAWING algorithm.pptx
Computer graphics LINE DRAWING algorithm.pptxComputer graphics LINE DRAWING algorithm.pptx
Computer graphics LINE DRAWING algorithm.pptx
R S Anu Prabha
 
Computer Graphics_Module 2_Output Primitives.pdf
Computer Graphics_Module 2_Output Primitives.pdfComputer Graphics_Module 2_Output Primitives.pdf
Computer Graphics_Module 2_Output Primitives.pdf
tabbu23
 
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
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
Omprakash Chauhan
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
TutorialsDuniya.com
 
Ad

More from Drishti Bhalla (16)

Propositions - Discrete Structures
Propositions - Discrete Structures Propositions - Discrete Structures
Propositions - Discrete Structures
Drishti Bhalla
 
Physical Layer Numericals - Data Communication & Networking
Physical Layer  Numericals - Data Communication & NetworkingPhysical Layer  Numericals - Data Communication & Networking
Physical Layer Numericals - Data Communication & Networking
Drishti Bhalla
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - Mathematics
Drishti Bhalla
 
Matrices - Mathematics
Matrices - MathematicsMatrices - Mathematics
Matrices - Mathematics
Drishti Bhalla
 
Holy Rivers - Hindi
Holy Rivers - HindiHoly Rivers - Hindi
Holy Rivers - Hindi
Drishti Bhalla
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating Systems
Drishti Bhalla
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
Drishti Bhalla
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software Engineering
Drishti Bhalla
 
Performance Management and Feedback - SHRM
Performance Management and Feedback - SHRMPerformance Management and Feedback - SHRM
Performance Management and Feedback - SHRM
Drishti Bhalla
 
Computer System Architecture - BUN instruction
Computer System Architecture - BUN instructionComputer System Architecture - BUN instruction
Computer System Architecture - BUN instruction
Drishti Bhalla
 
King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4
Drishti Bhalla
 
Information Technology - System Threats
Information Technology - System ThreatsInformation Technology - System Threats
Information Technology - System Threats
Drishti Bhalla
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software Engineering
Drishti Bhalla
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of Computation
Drishti Bhalla
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
Drishti Bhalla
 
Propositions - Discrete Structures
Propositions - Discrete Structures Propositions - Discrete Structures
Propositions - Discrete Structures
Drishti Bhalla
 
Physical Layer Numericals - Data Communication & Networking
Physical Layer  Numericals - Data Communication & NetworkingPhysical Layer  Numericals - Data Communication & Networking
Physical Layer Numericals - Data Communication & Networking
Drishti Bhalla
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - Mathematics
Drishti Bhalla
 
Matrices - Mathematics
Matrices - MathematicsMatrices - Mathematics
Matrices - Mathematics
Drishti Bhalla
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating Systems
Drishti Bhalla
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
Drishti Bhalla
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software Engineering
Drishti Bhalla
 
Performance Management and Feedback - SHRM
Performance Management and Feedback - SHRMPerformance Management and Feedback - SHRM
Performance Management and Feedback - SHRM
Drishti Bhalla
 
Computer System Architecture - BUN instruction
Computer System Architecture - BUN instructionComputer System Architecture - BUN instruction
Computer System Architecture - BUN instruction
Drishti Bhalla
 
King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4
Drishti Bhalla
 
Information Technology - System Threats
Information Technology - System ThreatsInformation Technology - System Threats
Information Technology - System Threats
Drishti Bhalla
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software Engineering
Drishti Bhalla
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of Computation
Drishti Bhalla
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
Drishti Bhalla
 
Ad

Recently uploaded (20)

362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbbTree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
Structural Design for Residential-to-Restaurant Conversion
Structural Design for Residential-to-Restaurant ConversionStructural Design for Residential-to-Restaurant Conversion
Structural Design for Residential-to-Restaurant Conversion
DanielRoman285499
 
Airport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptxAirport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptx
BibekMedhi2
 
社内勉強会資料_Chain of Thought .
社内勉強会資料_Chain of Thought                           .社内勉強会資料_Chain of Thought                           .
社内勉強会資料_Chain of Thought .
NABLAS株式会社
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Impurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptxImpurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptx
dhanashree78
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible PavementsPavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyRigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
Introduction to AI agent development with MCP
Introduction to AI agent development with MCPIntroduction to AI agent development with MCP
Introduction to AI agent development with MCP
Dori Waldman
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
Flow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docxFlow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docx
rifka575530
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) ProjectMontreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
Computer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdfComputer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdf
kumarprem6767merp
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbbTree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
Structural Design for Residential-to-Restaurant Conversion
Structural Design for Residential-to-Restaurant ConversionStructural Design for Residential-to-Restaurant Conversion
Structural Design for Residential-to-Restaurant Conversion
DanielRoman285499
 
Airport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptxAirport_Substation_With_Diagrams (2).pptx
Airport_Substation_With_Diagrams (2).pptx
BibekMedhi2
 
社内勉強会資料_Chain of Thought .
社内勉強会資料_Chain of Thought                           .社内勉強会資料_Chain of Thought                           .
社内勉強会資料_Chain of Thought .
NABLAS株式会社
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Impurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptxImpurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptx
dhanashree78
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible PavementsPavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyRigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
Introduction to AI agent development with MCP
Introduction to AI agent development with MCPIntroduction to AI agent development with MCP
Introduction to AI agent development with MCP
Dori Waldman
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
Flow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docxFlow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docx
rifka575530
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) ProjectMontreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
Computer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdfComputer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdf
kumarprem6767merp
 

Mid point line Algorithm - Computer Graphics

  • 1. MID-POINT LINE PLOTTING ALGORITHM MADE BY: DIMPY CHUGH (1833) DRISHTI BHALLA (1838)
  • 2. INTRODUCTION The Midpoint line algorithm is an incremental line plotting algorithm i.e. at each step we make incremental calculations based on preceding step to find next y value, in order to form a close approximation to a straight line between two points.  It chooses the pixels closest to the line with accuracy, consistency and straightness.  It is very simple and requires only integer data and simple arithmetic.  It avoids division and multiplication and thus avoid truncate errors. ADVANTAGES
  • 3. BASISOF ALGORITHM  Given the previous pixel P, there are two candidates for the next pixel closest to the line, E and NE .  If the M is above the line, choose E. If M is below the line, choose NE. Previous pixel Choices for current pixel Previous pixel Choices for current pixel
  • 4. Assumptions: Two end points of a line : (x0, y0) and (x1, y1) Also, x0 < x1 Since, we are sampling in x-direction, so, for the next pixel , x-coordinate will be xp+1 i.e. xp+ 1 and correspondingly we will calculate the value of y- coordinate . The implicit equation of a line is: F(x, y) = a x + b y + c …….(1) dx = x1 –x0 dy = y1 – y0 Slope intercept form a line is : y = m x+ B y = (dy/dx) x +B F(x,y)= (x)dy – (y)dx + Bdx ……(2) Comparing (1) and(2) we get, a= dy, b= -dx and c= Bdx DERIVATION
  • 5. M=(xp +1, yp+1/2) d= F(M)= F(xp +1, yp+1/2) - The sign of the decision variable ‘d’ is used to make the midpoint determination for all remaining pixels.  If d is negative, the midpoint is above the line and E is chosen i.e. (xp +1, yp) will be plotted.  If d is positive, the midpoint is below the line and NE is chosen, i.e. we will plot (xp +1, yp+1). As the algorithm progresses from pixel to pixel, d is calculated with one of two pre-calculated values based on the E/NE decision.  For all points on the line, the solution to F(x, y) is 0.  For all points above the line F(x, y) result in a negative number  For all points below F(x, y) result in a positive number. This relationship is used to determine the relative position of M.
  • 6. Case 1: If E is chosen (d<0) dnew= F(xp +2, yp+1/2) = a(xp +2) + b(yp+1/2) +c dold = a(xp+1) + b(yp+1/2)+c ∆d = dnew -dold = a(xp +2)- a(xp+1)+ b(yp+1/2)- b(yp+1/2)+c-c = a(xp) +2a –a(xp) –a = a. Therefore, dnew = dold + dy Case 2: If NE is chosen (d>0) dnew= F(xp +2, yp+3/2) = a(xp +2) + b(yp+3/2) +c dold = a(xp+1) + b(yp+1/2)+c ∆d = dnew -dold = a(xp +2)- a(xp+1)+ b(yp+3/2)- b(yp+1/2)+c-c = a(xp) +2a –a(xp) –a+ b(yp) +3/2b – b(yp) -1/2b = a+b Therefore, dnew = dold + dy-dx
  • 7. d0= F(x0+1 , y0+1/2) = a(x0+1) + b(y0+1/2) +c = ax0+ by0+c +a+ b/2 = F(x0,y0) + a+ b/2 = 0 + a+ b/2 ( a= dy, b= -dx) Therefore, d0 = dy - dx/2 Derivationforcalculatingthe initial value for d0
  • 8. ALGORITHM(|M|<1) 1) Input (x0,y0) and (x1,y1) 2) Calculate dy and dx 3) d= dy-(dx/2) 4) x= x0 and y=y0 5) Plot(x , y) 6) While(x<x1) 7) x=x+1 8) If(d<0) 9) d=d+dy 10) else 11) d=d+dy-dx 12) y=y+1 13) Plot(x,y)
  • 9. ALGORITHM (|M|>1) 1) Input (x0,y0) and (x1,y1) 2) Calculate dy and dx 3) d= dx-(dy/2) 4) x= x0 and y=y0 5) Plot(x , y) 6) While(y<y1) 7) y=y+1 8) If(d<0) 9) d=d+dx 10) else 11) d=d+dx-dy 12) x=x+1 13) Plot(x,y)
  • 10. EXAMPLE Draw a line from (4,8) to (9,12) and plot the points accordingly. Initially: (x,y)=(4,8) (x1,y1)=(9,12) dy=(y1-y0)= (12-8)= 4 dx= (x1-x0)=(9-4)= 5 Now, the first decision variable (d0)= dy- dx/2 = 4-5/2 = 1.5 As d0 >0 , NE is chosen and the next pixel to be plotted will be ( x+1,y+1) i.e. (5,9) -> d1= d0+ (dy-dx) = 1.5+ 4-5 = 0.5 As d1 >0 , again NE is chosen and the next pixel to be plotted will be ( x+1,y+1) i.e.(6,10)
  • 11. -> d2=d1+ dy-dx = 0.5+4-5 = -0.5 As d2 <0 , E is chosen and the next pixel to be plotted will be ( x+1,y) i.e. (7,10) -> d3= d2+dy = -0.5 + 4 = 3.5 As d3 >0 , NE is chosen and the next pixel to be plotted will be ( x+1,y+1) i.e. (8,11) -> d4= d3+dy-dx = 3.5+ 4-5 = 2.5 As d4 >0 , NE is chosen and the next pixel to be plotted will be ( x+1,y+1) i.e. (9,12) Now as we have reached our second end point i.e. (x1,y1)= (9,12) ,we will stop the procedure. Therefore, the plotted points on the grids will be (5,9) ,(6,10), ( 7,10) ,(8,11) and (9,12).