SlideShare a Scribd company logo
1 of 10
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

Scan line method
Scan line methodScan line method
Scan line methodPooja Dixit
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts
Image Interpolation Techniques with Optical and Digital Zoom ConceptsImage Interpolation Techniques with Optical and Digital Zoom Concepts
Image Interpolation Techniques with Optical and Digital Zoom Conceptsmmjalbiaty
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithmMani Kanth
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & DescriptorsPundrikPatel
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unitaravindangc
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clippingMani Kanth
 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
 
Visible surface identification
Visible surface identificationVisible surface identification
Visible surface identificationPooja Dixit
 
DBMS LECTURE NOTES FOR AKTU
DBMS LECTURE NOTES FOR AKTU DBMS LECTURE NOTES FOR AKTU
DBMS LECTURE NOTES FOR AKTU Sunit Mishra
 
Answers computer networks 159334 assignment_2_2010
Answers computer networks 159334 assignment_2_2010Answers computer networks 159334 assignment_2_2010
Answers computer networks 159334 assignment_2_2010Lakshmi Gupta
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse2013901097
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithmPooja Dixit
 
Log Transformation in Image Processing with Example
Log Transformation in Image Processing with ExampleLog Transformation in Image Processing with Example
Log Transformation in Image Processing with ExampleMustak Ahmmed
 
Comuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithmComuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithmRachana Marathe
 

What's hot (20)

Scan line method
Scan line methodScan line method
Scan line method
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts
Image Interpolation Techniques with Optical and Digital Zoom ConceptsImage Interpolation Techniques with Optical and Digital Zoom Concepts
Image Interpolation Techniques with Optical and Digital Zoom Concepts
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
 
UNIT-IV
UNIT-IVUNIT-IV
UNIT-IV
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
 
Circular queues
Circular queuesCircular queues
Circular queues
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Visible surface identification
Visible surface identificationVisible surface identification
Visible surface identification
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
DBMS LECTURE NOTES FOR AKTU
DBMS LECTURE NOTES FOR AKTU DBMS LECTURE NOTES FOR AKTU
DBMS LECTURE NOTES FOR AKTU
 
Answers computer networks 159334 assignment_2_2010
Answers computer networks 159334 assignment_2_2010Answers computer networks 159334 assignment_2_2010
Answers computer networks 159334 assignment_2_2010
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
HSV color model
HSV color modelHSV color model
HSV color model
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithm
 
Log Transformation in Image Processing with Example
Log Transformation in Image Processing with ExampleLog Transformation in Image Processing with Example
Log Transformation in Image Processing with Example
 
lecture2 computer graphics graphics hardware(Computer graphics tutorials)
 lecture2  computer graphics graphics hardware(Computer graphics tutorials) lecture2  computer graphics graphics hardware(Computer graphics tutorials)
lecture2 computer graphics graphics hardware(Computer graphics tutorials)
 
Comuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithmComuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithm
 

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.pptAliZaib71
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algoMohd Arif
 
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 AlgorithmMrinmoy Dalal
 
mid point algorithm.pdf
mid point algorithm.pdfmid point algorithm.pdf
mid point algorithm.pdfMehulMunshi3
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithmPooja Dixit
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivationMazharul Islam
 
Lec05 circle ellipse
Lec05 circle ellipseLec05 circle ellipse
Lec05 circle ellipseMaaz 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
 
10CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 610CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 6Vanishree Arun
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functionsTarun 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 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
 
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
 
Bresenham circle
Bresenham circleBresenham circle
Bresenham circle
 
Unit 3
Unit 3Unit 3
Unit 3
 

More from Pooja Dixit

Combinational circuit.pptx
Combinational circuit.pptxCombinational circuit.pptx
Combinational circuit.pptxPooja Dixit
 
number system.pptx
number system.pptxnumber system.pptx
number system.pptxPooja Dixit
 
Multiplexer.pptx
Multiplexer.pptxMultiplexer.pptx
Multiplexer.pptxPooja Dixit
 
Logic Gates.pptx
Logic Gates.pptxLogic Gates.pptx
Logic Gates.pptxPooja Dixit
 
Karnaugh Map Simplification Rules.pptx
Karnaugh Map Simplification Rules.pptxKarnaugh Map Simplification Rules.pptx
Karnaugh Map Simplification Rules.pptxPooja Dixit
 
Half Subtractor.pptx
Half Subtractor.pptxHalf Subtractor.pptx
Half Subtractor.pptxPooja Dixit
 
De-multiplexer.pptx
De-multiplexer.pptxDe-multiplexer.pptx
De-multiplexer.pptxPooja Dixit
 
DeMorgan’s Theory.pptx
DeMorgan’s Theory.pptxDeMorgan’s Theory.pptx
DeMorgan’s Theory.pptxPooja Dixit
 
Combinational circuit.pptx
Combinational circuit.pptxCombinational circuit.pptx
Combinational circuit.pptxPooja Dixit
 
Boolean Algebra.pptx
Boolean Algebra.pptxBoolean Algebra.pptx
Boolean Algebra.pptxPooja Dixit
 
Binary Multiplication & Division.pptx
Binary Multiplication & Division.pptxBinary Multiplication & Division.pptx
Binary Multiplication & Division.pptxPooja Dixit
 
Binary addition.pptx
Binary addition.pptxBinary addition.pptx
Binary addition.pptxPooja Dixit
 
Basics of Computer Organization.pptx
Basics of Computer Organization.pptxBasics of Computer Organization.pptx
Basics of Computer Organization.pptxPooja Dixit
 
Three Address code
Three Address code Three Address code
Three Address code Pooja Dixit
 
3 d viewing projection
3 d viewing  projection3 d viewing  projection
3 d viewing projectionPooja 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
 
3 d viewing projection
3 d viewing  projection3 d viewing  projection
3 d viewing projection
 

Recently uploaded

Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 

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