SlideShare a Scribd company logo
Prof. Neeraj Bhargava
Pooja Dixit
Department of Computer Science
School of Engineering & System Sciences
MDS, University Ajmer, Rajasthan, India
1
 The mid point circle algorithm is used to determine the pixels needed for
rasterizing a circle while drawing a circle on a pixel screen.
 In this technique algorithm determines the mid point between the next 2
possible consecutive pixels and then checks whether the mid point in inside
or outside the circle and illuminates the pixel accordingly.
 A circle is highly symmetrical and can be divided into 8 Octets on graph.
Lets take center of circle at Origin i.e (0,0) :
We need only to conclude the pixels of any one of the octet
rest we can conclude because of symmetrical properties of
circle.
2
 Let us Take Quadrant 1:
3
 Radius = OR = r
 Radius = x intercept = y intercept
 At point R
coordinate of x = coordinate of y or we can say x=y
 let us take Octet 2 of quadrant 1
 here first pixel would be (0,y)
here value of y intercept = radius (r)
 as circle’s center is at origin
4
 let us assume we have plotted Pixel P whose coordinates are
 Now we need to determine the next pixel.
 We have chosen octet 2 where circle is moving forward and downwards so y
can never be increased, either it can be same or decremented. Similarly x will
always be increasing as circle is moving forward too.
 So y is needed to be decided.
 Now we need to decide whether we should go with point N or S.
 For that decision Mid Point circle drawing technique will us decide our next
pixel whether it will be N or S.
 As is the next most pixel of therefore we can write,
 And similarly in this case.
 Let M is the midpoint between and .
 And coordinates of point (M) are
5
6
(x– h)2 + (y – k)2 = r2
When coordinates of centre are at Origin i.e., (h=0, k=0)
x2 + y2 = r2 (Pythagoras theorem
Function of Circle Equation
Function of Midpoint M (xk+1 , yk -1/2) in circle equation
F(M)= xk+1
2 + (yk -1/2)2 - r2
= (xk+1)2 + (yk -1/2)2 - r2
The above equation is too our decision parameter pk
Pk = (xk+1)2 + (yk -1/2)2 - r2 …….(i)
To find out the next decition parameter we need to get Pk+1
Pk+1 = (xk+1+1)2 + (yk+1 -1/2)2 - r2
Now,
Pk+1- Pk = (xk+1+1)2 + (yk+1 -1/2)2 - r2 -[(xk+1)2 + (yk -1/2)2 - r2]
= ((xk+1)+1)2 + (yk+1 -1/2)2 - (xk+1)2 - (yk -1/2)2
= (xk+1)2 + 1 +2(xk+1) + yk+1
2 +(1/4) - yk+1 - (xk+1)2 - yk
2 – (1/4) + yk+1
= 2(xk+1) + yk+1
2 - yk
2 - yk+1 + yk +1
= 2(xk+1) +( yk+1
2 - yk
2 ) - (yk+1 - yk) +1
Pk+1 = Pk + 2(xk+1)+( yk+1
2 - yk
2 ) - (yk+1 - yk) +1 …..(ii)
F(C) = x2 + y2 - r2
 Now let us conclude the initial decision parameter
 For that we have to choose coordinates of starting point i.e. (0,r)
 Put this in (i) i.e. Pk
Pk = (xk+1)2 + (yk -1/2)2 - r2
P0 = (0+1)2 + (r -1/2)2 - r2
= 1 + r2 + ¼ - r – r2
= 1 + ¼ - r
…..(initial decision parameter)
 Now If Pk ≥ 0 that means midpoint is outside the circle and S is closest pixel
so we will choose S (xk+1,yk-1)
That means yk+1 = yk-1
Putting coordinates of S in (ii) then,
Pk+1 = Pk + 2(xk+1)+( yk-1
2 - yk
2 ) - (yk-1 - yk) +1
= Pk + 2(xk+1)+( yk -1)2 - yk
2 ) - ((yk-1) - yk) +1
= Pk + 2(xk+1)+yk
2+1-2yk - yk
2 - yk+1 + yk +1
= Pk + 2(xk+1)-2yk +2 + 1
= Pk + 2(xk+1)-2(yk -1) + 1
7
 As we know (xk+1 = xk+1) and (yk-1 = yk-1)
 Therefore,
Pk+1 = Pk + 2xk+1 - 2yk-1 + 1
 And if Pk < 0 that means midpoint is inside the circle and N is closest pixel
so we will choose N (xk+1 , yk)
Now put coordinates of N in (ii)
Pk+1 = Pk + 2(xk+1)+( yk
2 - yk
2 ) - (yk - yk) +1
= Pk + 2(xk+1)+( yk
2 - yk
2 ) - (yk - yk) +1
= Pk + 2(xk+1) +1
as xk+1 = xk+1 , therefore,
Pk+1 = Pk + 2xk+1 +1
Hence we have derived the mid point circle drawing algorithm.
8
Program:-
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void bcircle(int xcent,int ycent,int x,int y);
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm," ");
int x=0,y,d,r,xcent=300,ycent=300;
cout<<"Enter the radius";
cin>>r;
y=r;
d=5/4-r;
while(x<y)
{
bcircle(xcent,ycent,x,y);
if(d<0)
{
x=x+1;
d=d+2*x+1;
} 9
else
{
x=x+1;
y=y-1;
d=d+2*(x-y)+1;
}
}
getch();
}
void bcircle(int xcent,int ycent,int x,int y)
{
putpixel(xcent-x,ycent-y,6);
putpixel(xcent-y,ycent-x,12);
putpixel(xcent+y,ycent-x,24);
putpixel(xcent+x,ycent-y,14);
putpixel(xcent+x,ycent+y,13);
putpixel(xcent+y,ycent+x,9);
putpixel(xcent-y,ycent+x,27);
putpixel(xcent-x,ycent+y,5);
getch();
closegraph();
}
Output :-
enter the values for x and y: 250 300
enter the value for radius:60
10

More Related Content

What's hot

2.2. interactive computer graphics
2.2. interactive computer graphics2.2. interactive computer graphics
2.2. interactive computer graphics
Ratnadeepsinh Jadeja
 
Image processing7 frequencyfiltering
Image processing7 frequencyfilteringImage processing7 frequencyfiltering
Image processing7 frequencyfiltering
shabanam tamboli
 
Interpixel redundancy
Interpixel redundancyInterpixel redundancy
Interpixel redundancy
Naveen Kumar
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
kanikkk
 
Fractal Image Compression Using Quadtree Decomposition
Fractal Image Compression Using Quadtree DecompositionFractal Image Compression Using Quadtree Decomposition
Fractal Image Compression Using Quadtree Decomposition
Harshit Varshney
 
Digtial Image Processing Q@A
Digtial Image Processing Q@ADigtial Image Processing Q@A
Digtial Image Processing Q@A
Chung Hua Universit
 
Lecture 14 Properties of Fourier Transform for 2D Signal
Lecture 14 Properties of Fourier Transform for 2D SignalLecture 14 Properties of Fourier Transform for 2D Signal
Lecture 14 Properties of Fourier Transform for 2D Signal
VARUN KUMAR
 
Chapter 1 introduction (Image Processing)
Chapter 1 introduction (Image Processing)Chapter 1 introduction (Image Processing)
Chapter 1 introduction (Image Processing)
Varun Ojha
 
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
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
PundrikPatel
 
Knowledge Representation, Inference and Reasoning
Knowledge Representation, Inference and ReasoningKnowledge Representation, Inference and Reasoning
Knowledge Representation, Inference and Reasoning
Sagacious IT Solution
 
color image processing
color image processingcolor image processing
color image processing
HemanthvenkataSaiA
 
Image compression .
Image compression .Image compression .
Image compression .
Payal Vishwakarma
 
Dilation and erosion
Dilation and erosionDilation and erosion
Dilation and erosionAswin Pv
 
Full resolution image compression with recurrent neural networks
Full resolution image compression with  recurrent neural networksFull resolution image compression with  recurrent neural networks
Full resolution image compression with recurrent neural networks
Ashis Kumar Chanda
 
Computer Graphics Introduction
Computer Graphics IntroductionComputer Graphics Introduction
Computer Graphics IntroductionGhaffar Khan
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domainAshish Kumar
 
COMPUTER GRAPHICS
COMPUTER GRAPHICSCOMPUTER GRAPHICS
COMPUTER GRAPHICS
Jagan Raja
 

What's hot (20)

2.2. interactive computer graphics
2.2. interactive computer graphics2.2. interactive computer graphics
2.2. interactive computer graphics
 
Pixel relationships
Pixel relationshipsPixel relationships
Pixel relationships
 
Image processing7 frequencyfiltering
Image processing7 frequencyfilteringImage processing7 frequencyfiltering
Image processing7 frequencyfiltering
 
Interpixel redundancy
Interpixel redundancyInterpixel redundancy
Interpixel redundancy
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
 
Fractal Image Compression Using Quadtree Decomposition
Fractal Image Compression Using Quadtree DecompositionFractal Image Compression Using Quadtree Decomposition
Fractal Image Compression Using Quadtree Decomposition
 
Digtial Image Processing Q@A
Digtial Image Processing Q@ADigtial Image Processing Q@A
Digtial Image Processing Q@A
 
Lecture 14 Properties of Fourier Transform for 2D Signal
Lecture 14 Properties of Fourier Transform for 2D SignalLecture 14 Properties of Fourier Transform for 2D Signal
Lecture 14 Properties of Fourier Transform for 2D Signal
 
Chapter 1 introduction (Image Processing)
Chapter 1 introduction (Image Processing)Chapter 1 introduction (Image Processing)
Chapter 1 introduction (Image Processing)
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
 
Knowledge Representation, Inference and Reasoning
Knowledge Representation, Inference and ReasoningKnowledge Representation, Inference and Reasoning
Knowledge Representation, Inference and Reasoning
 
color image processing
color image processingcolor image processing
color image processing
 
Image compression .
Image compression .Image compression .
Image compression .
 
Dilation and erosion
Dilation and erosionDilation and erosion
Dilation and erosion
 
Full resolution image compression with recurrent neural networks
Full resolution image compression with  recurrent neural networksFull resolution image compression with  recurrent neural networks
Full resolution image compression with recurrent neural networks
 
Computer Graphics Introduction
Computer Graphics IntroductionComputer Graphics Introduction
Computer Graphics Introduction
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domain
 
COMPUTER GRAPHICS
COMPUTER GRAPHICSCOMPUTER GRAPHICS
COMPUTER GRAPHICS
 
Histogram processing
Histogram processingHistogram processing
Histogram processing
 

Similar to Circle algorithm

Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
AliZaib71
 
10994479.ppt
10994479.ppt10994479.ppt
10994479.ppt
ALIZAIB KHAN
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algoMohd Arif
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
2013901097
 
Computer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipseComputer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipse
Hisham Al Kurdi, EAVA, DMC-D-4K, HCCA-P, HCAA-D
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing Algorithm
Mrinmoy Dalal
 
mid point algorithm.pdf
mid point algorithm.pdfmid point algorithm.pdf
mid point algorithm.pdf
MehulMunshi3
 
2.circle
2.circle2.circle
2.circle
SakshiNailwal
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
Pooja Dixit
 
3. apply distance and midpoint
3.  apply distance and midpoint3.  apply distance and midpoint
3. apply distance and midpoint
Regina McDonald, MA.Ed
 
Comuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithmComuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithm
Rachana Marathe
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivation
Mazharul Islam
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
Shweta Patil
 
Lec05 circle ellipse
Lec05 circle ellipseLec05 circle ellipse
Lec05 circle ellipse
Maaz Rizwan
 
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
 
1513 circles
1513 circles1513 circles
1513 circles
Dr Fereidoun Dejahang
 
10CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 610CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 6
Vanishree Arun
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functions
Tarun Gehlot
 

Similar to Circle algorithm (20)

Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
 
10994479.ppt
10994479.ppt10994479.ppt
10994479.ppt
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algo
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
Computer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipseComputer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipse
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing Algorithm
 
mid point algorithm.pdf
mid point algorithm.pdfmid point algorithm.pdf
mid point algorithm.pdf
 
2.circle
2.circle2.circle
2.circle
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
 
3. apply distance and midpoint
3.  apply distance and midpoint3.  apply distance and midpoint
3. apply distance and midpoint
 
Comuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithmComuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithm
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivation
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Lec05 circle ellipse
Lec05 circle ellipseLec05 circle ellipse
Lec05 circle ellipse
 
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...
 
1513 circles
1513 circles1513 circles
1513 circles
 
10CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 610CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 6
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functions
 

More from Pooja Dixit

Combinational circuit.pptx
Combinational circuit.pptxCombinational circuit.pptx
Combinational circuit.pptx
Pooja Dixit
 
number system.pptx
number system.pptxnumber system.pptx
number system.pptx
Pooja Dixit
 
Multiplexer.pptx
Multiplexer.pptxMultiplexer.pptx
Multiplexer.pptx
Pooja Dixit
 
Logic Gates.pptx
Logic Gates.pptxLogic Gates.pptx
Logic Gates.pptx
Pooja Dixit
 
K-Map.pptx
K-Map.pptxK-Map.pptx
K-Map.pptx
Pooja Dixit
 
Karnaugh Map Simplification Rules.pptx
Karnaugh Map Simplification Rules.pptxKarnaugh Map Simplification Rules.pptx
Karnaugh Map Simplification Rules.pptx
Pooja Dixit
 
Half Subtractor.pptx
Half Subtractor.pptxHalf Subtractor.pptx
Half Subtractor.pptx
Pooja Dixit
 
Gray Code.pptx
Gray Code.pptxGray Code.pptx
Gray Code.pptx
Pooja Dixit
 
Flip Flop.pptx
Flip Flop.pptxFlip Flop.pptx
Flip Flop.pptx
Pooja Dixit
 
Encoder.pptx
Encoder.pptxEncoder.pptx
Encoder.pptx
Pooja Dixit
 
De-multiplexer.pptx
De-multiplexer.pptxDe-multiplexer.pptx
De-multiplexer.pptx
Pooja Dixit
 
DeMorgan’s Theory.pptx
DeMorgan’s Theory.pptxDeMorgan’s Theory.pptx
DeMorgan’s Theory.pptx
Pooja Dixit
 
Combinational circuit.pptx
Combinational circuit.pptxCombinational circuit.pptx
Combinational circuit.pptx
Pooja Dixit
 
Boolean Algebra.pptx
Boolean Algebra.pptxBoolean Algebra.pptx
Boolean Algebra.pptx
Pooja Dixit
 
Binary Multiplication & Division.pptx
Binary Multiplication & Division.pptxBinary Multiplication & Division.pptx
Binary Multiplication & Division.pptx
Pooja Dixit
 
Binary addition.pptx
Binary addition.pptxBinary addition.pptx
Binary addition.pptx
Pooja Dixit
 
Basics of Computer Organization.pptx
Basics of Computer Organization.pptxBasics of Computer Organization.pptx
Basics of Computer Organization.pptx
Pooja Dixit
 
Decoders
DecodersDecoders
Decoders
Pooja Dixit
 
Three Address code
Three Address code Three Address code
Three Address code
Pooja Dixit
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithm
Pooja Dixit
 

More from Pooja Dixit (20)

Combinational circuit.pptx
Combinational circuit.pptxCombinational circuit.pptx
Combinational circuit.pptx
 
number system.pptx
number system.pptxnumber system.pptx
number system.pptx
 
Multiplexer.pptx
Multiplexer.pptxMultiplexer.pptx
Multiplexer.pptx
 
Logic Gates.pptx
Logic Gates.pptxLogic Gates.pptx
Logic Gates.pptx
 
K-Map.pptx
K-Map.pptxK-Map.pptx
K-Map.pptx
 
Karnaugh Map Simplification Rules.pptx
Karnaugh Map Simplification Rules.pptxKarnaugh Map Simplification Rules.pptx
Karnaugh Map Simplification Rules.pptx
 
Half Subtractor.pptx
Half Subtractor.pptxHalf Subtractor.pptx
Half Subtractor.pptx
 
Gray Code.pptx
Gray Code.pptxGray Code.pptx
Gray Code.pptx
 
Flip Flop.pptx
Flip Flop.pptxFlip Flop.pptx
Flip Flop.pptx
 
Encoder.pptx
Encoder.pptxEncoder.pptx
Encoder.pptx
 
De-multiplexer.pptx
De-multiplexer.pptxDe-multiplexer.pptx
De-multiplexer.pptx
 
DeMorgan’s Theory.pptx
DeMorgan’s Theory.pptxDeMorgan’s Theory.pptx
DeMorgan’s Theory.pptx
 
Combinational circuit.pptx
Combinational circuit.pptxCombinational circuit.pptx
Combinational circuit.pptx
 
Boolean Algebra.pptx
Boolean Algebra.pptxBoolean Algebra.pptx
Boolean Algebra.pptx
 
Binary Multiplication & Division.pptx
Binary Multiplication & Division.pptxBinary Multiplication & Division.pptx
Binary Multiplication & Division.pptx
 
Binary addition.pptx
Binary addition.pptxBinary addition.pptx
Binary addition.pptx
 
Basics of Computer Organization.pptx
Basics of Computer Organization.pptxBasics of Computer Organization.pptx
Basics of Computer Organization.pptx
 
Decoders
DecodersDecoders
Decoders
 
Three Address code
Three Address code Three Address code
Three Address code
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithm
 

Recently uploaded

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
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
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
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
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
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
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
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
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 

Recently uploaded (20)

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
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
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
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
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
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
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 

Circle algorithm

  • 1. Prof. Neeraj Bhargava Pooja Dixit Department of Computer Science School of Engineering & System Sciences MDS, University Ajmer, Rajasthan, India 1
  • 2.  The mid point circle algorithm is used to determine the pixels needed for rasterizing a circle while drawing a circle on a pixel screen.  In this technique algorithm determines the mid point between the next 2 possible consecutive pixels and then checks whether the mid point in inside or outside the circle and illuminates the pixel accordingly.  A circle is highly symmetrical and can be divided into 8 Octets on graph. Lets take center of circle at Origin i.e (0,0) : We need only to conclude the pixels of any one of the octet rest we can conclude because of symmetrical properties of circle. 2
  • 3.  Let us Take Quadrant 1: 3
  • 4.  Radius = OR = r  Radius = x intercept = y intercept  At point R coordinate of x = coordinate of y or we can say x=y  let us take Octet 2 of quadrant 1  here first pixel would be (0,y) here value of y intercept = radius (r)  as circle’s center is at origin 4
  • 5.  let us assume we have plotted Pixel P whose coordinates are  Now we need to determine the next pixel.  We have chosen octet 2 where circle is moving forward and downwards so y can never be increased, either it can be same or decremented. Similarly x will always be increasing as circle is moving forward too.  So y is needed to be decided.  Now we need to decide whether we should go with point N or S.  For that decision Mid Point circle drawing technique will us decide our next pixel whether it will be N or S.  As is the next most pixel of therefore we can write,  And similarly in this case.  Let M is the midpoint between and .  And coordinates of point (M) are 5
  • 6. 6 (x– h)2 + (y – k)2 = r2 When coordinates of centre are at Origin i.e., (h=0, k=0) x2 + y2 = r2 (Pythagoras theorem Function of Circle Equation Function of Midpoint M (xk+1 , yk -1/2) in circle equation F(M)= xk+1 2 + (yk -1/2)2 - r2 = (xk+1)2 + (yk -1/2)2 - r2 The above equation is too our decision parameter pk Pk = (xk+1)2 + (yk -1/2)2 - r2 …….(i) To find out the next decition parameter we need to get Pk+1 Pk+1 = (xk+1+1)2 + (yk+1 -1/2)2 - r2 Now, Pk+1- Pk = (xk+1+1)2 + (yk+1 -1/2)2 - r2 -[(xk+1)2 + (yk -1/2)2 - r2] = ((xk+1)+1)2 + (yk+1 -1/2)2 - (xk+1)2 - (yk -1/2)2 = (xk+1)2 + 1 +2(xk+1) + yk+1 2 +(1/4) - yk+1 - (xk+1)2 - yk 2 – (1/4) + yk+1 = 2(xk+1) + yk+1 2 - yk 2 - yk+1 + yk +1 = 2(xk+1) +( yk+1 2 - yk 2 ) - (yk+1 - yk) +1 Pk+1 = Pk + 2(xk+1)+( yk+1 2 - yk 2 ) - (yk+1 - yk) +1 …..(ii) F(C) = x2 + y2 - r2
  • 7.  Now let us conclude the initial decision parameter  For that we have to choose coordinates of starting point i.e. (0,r)  Put this in (i) i.e. Pk Pk = (xk+1)2 + (yk -1/2)2 - r2 P0 = (0+1)2 + (r -1/2)2 - r2 = 1 + r2 + ¼ - r – r2 = 1 + ¼ - r …..(initial decision parameter)  Now If Pk ≥ 0 that means midpoint is outside the circle and S is closest pixel so we will choose S (xk+1,yk-1) That means yk+1 = yk-1 Putting coordinates of S in (ii) then, Pk+1 = Pk + 2(xk+1)+( yk-1 2 - yk 2 ) - (yk-1 - yk) +1 = Pk + 2(xk+1)+( yk -1)2 - yk 2 ) - ((yk-1) - yk) +1 = Pk + 2(xk+1)+yk 2+1-2yk - yk 2 - yk+1 + yk +1 = Pk + 2(xk+1)-2yk +2 + 1 = Pk + 2(xk+1)-2(yk -1) + 1 7
  • 8.  As we know (xk+1 = xk+1) and (yk-1 = yk-1)  Therefore, Pk+1 = Pk + 2xk+1 - 2yk-1 + 1  And if Pk < 0 that means midpoint is inside the circle and N is closest pixel so we will choose N (xk+1 , yk) Now put coordinates of N in (ii) Pk+1 = Pk + 2(xk+1)+( yk 2 - yk 2 ) - (yk - yk) +1 = Pk + 2(xk+1)+( yk 2 - yk 2 ) - (yk - yk) +1 = Pk + 2(xk+1) +1 as xk+1 = xk+1 , therefore, Pk+1 = Pk + 2xk+1 +1 Hence we have derived the mid point circle drawing algorithm. 8
  • 9. Program:- #include<iostream.h> #include<conio.h> #include<graphics.h> #include<math.h> void bcircle(int xcent,int ycent,int x,int y); void main() { int gd=DETECT,gm; initgraph(&gd,&gm," "); int x=0,y,d,r,xcent=300,ycent=300; cout<<"Enter the radius"; cin>>r; y=r; d=5/4-r; while(x<y) { bcircle(xcent,ycent,x,y); if(d<0) { x=x+1; d=d+2*x+1; } 9
  • 10. else { x=x+1; y=y-1; d=d+2*(x-y)+1; } } getch(); } void bcircle(int xcent,int ycent,int x,int y) { putpixel(xcent-x,ycent-y,6); putpixel(xcent-y,ycent-x,12); putpixel(xcent+y,ycent-x,24); putpixel(xcent+x,ycent-y,14); putpixel(xcent+x,ycent+y,13); putpixel(xcent+y,ycent+x,9); putpixel(xcent-y,ycent+x,27); putpixel(xcent-x,ycent+y,5); getch(); closegraph(); } Output :- enter the values for x and y: 250 300 enter the value for radius:60 10