SlideShare a Scribd company logo
1 of 14
Download to read offline
A Circle Drawing Algorithm
• The equation for a circle is:
• where r is the radius of the circle
• So, we can write a simple circle drawing algorithm by solving
the equation for y at unit x intervals using:
2
2
2
r
y
x =
+
2
2
x
r
y −
±
=
Direct circle algorithm
• Cartesian coordinates
• Circle equation:
( x - xc )2 + ( y - yc )2 = r2
• Step along x axis from xc - r to xc + r and
calculate
y = yc ± √ r2 - ( x - xc )2
Figure 6-11 Circle with center coordinates (xc , yc) and radius r .
Figure 6-12 Upper half of a
circle plotted with Equation 6-27
and with (xc , yc) = (0, 0).
Eight-Way Symmetry
•
(y,x)
(x,y)
(x, -y)
(y, -x)
(-x, -y)
(-y, -x)
(-x,y)
(-x, y)
2
R
Mid-Point Circle Algorithm
In the mid-point circle algorithm we use eight-way symmetry so
only ever calculate the points for the top right eighth of a circle,
and then use symmetry to get the rest of the points
Mid-Point Circle Algorithm (cont…)
(xk+1, yk)
(xk+1, yk-1)
(xk, yk)
•Assume that we have
just plotted point (xk, yk)
•The next point is a
choice between (xk+1, yk)
and (xk+1, yk-1)
•We would like to choose
the point that is nearest to
the actual circle
Mid-Point Circle Algorithm
•Let’s re-jig the equation of the circle slightly to give us:
•The equation evaluates as follows:
•By evaluating this function at the midpoint between the
candidate pixels we can make our decision
2
2
2
)
,
( r
y
x
y
x
fcirc −
+
=





>
=
<
,
0
,
0
,
0
)
,
( y
x
fcirc
boundary
circle
the
inside
is
)
,
(
if y
x
boundary
circle
on the
is
)
,
(
if y
x
boundary
circle
the
outside
is
)
,
(
if y
x
Mid-Point Circle Algorithm
• Assuming we have just plotted the pixel at (xk,yk) so we need to
choose between (xk+1,yk) and (xk+1,yk-1)
• Our decision variable can be defined as:
• If pk < 0 the midpoint is inside the circle and the pixel at yk is
closer to the circle
• Otherwise the midpoint is outside and yk-1 is closer
2
2
2
)
2
1
(
)
1
(
)
2
1
,
1
(
r
y
x
y
x
f
p
k
k
k
k
circ
k
−
−
+
+
=
−
+
=
Mid-Point Circle Algorithm (cont…)
• To ensure things are as efficient as possible we can do all of our
calculations incrementally
• First consider:
or:
where yk+1 is either yk or yk-1 depending on the sign of pk
( )
( ) 2
2
1
2
1
1
1
2
1
]
1
)
1
[(
2
1
,
1
r
y
x
y
x
f
p
k
k
k
k
circ
k
−
−
+
+
+
=
−
+
=
+
+
+
+
1
)
(
)
(
)
1
(
2 1
2
2
1
1 +
−
−
−
+
+
+
= +
+
+ k
k
k
k
k
k
k y
y
y
y
x
p
p
Mid-Point Circle Algorithm (cont…)
•The first decision variable is given as:
•Then if pk < 0 then the next decision variable is given as:
• If pk > 0 then the decision variable is:
r
r
r
r
f
p circ
−
=
−
−
+
=
−
=
4
5
)
2
1
(
1
)
2
1
,
1
(
2
2
0
1
2 1
1 +
+
= +
+ k
k
k x
p
p
1
2
1
2 1
1 +
−
+
+
= +
+ k
k
k
k y
x
p
p
The Mid-Point Circle Algorithm
• Input radius r and circle centre (xc, yc), then set the
coordinates for the first point on the circumference of a
circle centred on the origin as:
• Calculate the initial value of the decision parameter as:
• Starting with k = 0 at each position xk, perform the following
test. If pk < 0, the next point along the circle centred on (0,
0) is (xk+1, yk) and:
)
,
0
(
)
,
( 0
0 r
y
x =
r
p −
=
4
5
0
1
2 1
1 +
+
= +
+ k
k
k x
p
p
The Mid-Point Circle Algorithm
• Otherwise the next point along the circle is (xk+1, yk-
1) and:
4. Determine symmetry points in the other seven octants
5. Move each calculated pixel position (x, y) onto the
circular path centred at (xc, yc) to plot the coordinate
values:
6. Repeat steps 3 to 5 until x >= y
1
1
1 2
1
2 +
+
+ −
+
+
= k
k
k
k y
x
p
p
c
x
x
x +
= c
y
y
y +
=
Mid-Point Circle Algorithm Summary
– Eight-way symmetry can hugely reduce the work in
drawing a circle
– Moving in unit steps along the x axis at each point along
the circle’s edge we need to choose between two possible
y coordinates

More Related Content

Similar to mid point algorithm.pdf

Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse2013901097
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimediasaranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivessaranyan75
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivationMazharul Islam
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxKokebe2
 
Obj. 60 Circles in the Coordinate Plane
Obj. 60 Circles in the Coordinate PlaneObj. 60 Circles in the Coordinate Plane
Obj. 60 Circles in the Coordinate Planesmiller5
 
Circle algorithm
Circle algorithmCircle algorithm
Circle algorithmPooja 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 cppAlamgir Hossain
 
6.14.2 Circle Equations
6.14.2 Circle Equations6.14.2 Circle Equations
6.14.2 Circle Equationssmiller5
 
1.1.3 Circle Equations
1.1.3 Circle Equations1.1.3 Circle Equations
1.1.3 Circle Equationssmiller5
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxNaveenaKarthik3
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithmAnkit Garg
 

Similar to mid point algorithm.pdf (20)

Unit 3
Unit 3Unit 3
Unit 3
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Computer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipseComputer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipse
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
PPT_14.pptx
PPT_14.pptxPPT_14.pptx
PPT_14.pptx
 
CG-Lecture3.pptx
CG-Lecture3.pptxCG-Lecture3.pptx
CG-Lecture3.pptx
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivation
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
 
Obj. 60 Circles in the Coordinate Plane
Obj. 60 Circles in the Coordinate PlaneObj. 60 Circles in the Coordinate Plane
Obj. 60 Circles in the Coordinate Plane
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
 
Circle algorithm
Circle algorithmCircle algorithm
Circle algorithm
 
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
 
6.14.2 Circle Equations
6.14.2 Circle Equations6.14.2 Circle Equations
6.14.2 Circle Equations
 
1.1.3 Circle Equations
1.1.3 Circle Equations1.1.3 Circle Equations
1.1.3 Circle Equations
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Circle
CircleCircle
Circle
 

More from MehulMunshi3

Ch-3--Product_Design.pdf
Ch-3--Product_Design.pdfCh-3--Product_Design.pdf
Ch-3--Product_Design.pdfMehulMunshi3
 
Ch-4--Manufacturing_Process_Selection_and_Design.pdf
Ch-4--Manufacturing_Process_Selection_and_Design.pdfCh-4--Manufacturing_Process_Selection_and_Design.pdf
Ch-4--Manufacturing_Process_Selection_and_Design.pdfMehulMunshi3
 
Synthetic Curves.pdf
Synthetic Curves.pdfSynthetic Curves.pdf
Synthetic Curves.pdfMehulMunshi3
 
2D Translation.pdf
2D Translation.pdf2D Translation.pdf
2D Translation.pdfMehulMunshi3
 
SUPER ALLOYS_1.pdf
SUPER ALLOYS_1.pdfSUPER ALLOYS_1.pdf
SUPER ALLOYS_1.pdfMehulMunshi3
 
ty mech 22 papers 6th sem.pdf
ty mech 22 papers 6th sem.pdfty mech 22 papers 6th sem.pdf
ty mech 22 papers 6th sem.pdfMehulMunshi3
 
ty 2018 atkt papers.pdf
ty 2018 atkt papers.pdfty 2018 atkt papers.pdf
ty 2018 atkt papers.pdfMehulMunshi3
 

More from MehulMunshi3 (12)

Ch-3--Product_Design.pdf
Ch-3--Product_Design.pdfCh-3--Product_Design.pdf
Ch-3--Product_Design.pdf
 
Intro_to_OR.pdf
Intro_to_OR.pdfIntro_to_OR.pdf
Intro_to_OR.pdf
 
Ch-4--Manufacturing_Process_Selection_and_Design.pdf
Ch-4--Manufacturing_Process_Selection_and_Design.pdfCh-4--Manufacturing_Process_Selection_and_Design.pdf
Ch-4--Manufacturing_Process_Selection_and_Design.pdf
 
Synthetic Curves.pdf
Synthetic Curves.pdfSynthetic Curves.pdf
Synthetic Curves.pdf
 
2D Translation.pdf
2D Translation.pdf2D Translation.pdf
2D Translation.pdf
 
SUPER ALLOYS_1.pdf
SUPER ALLOYS_1.pdfSUPER ALLOYS_1.pdf
SUPER ALLOYS_1.pdf
 
SUPER ALLOYS.pdf
SUPER ALLOYS.pdfSUPER ALLOYS.pdf
SUPER ALLOYS.pdf
 
ty mech 22 papers 6th sem.pdf
ty mech 22 papers 6th sem.pdfty mech 22 papers 6th sem.pdf
ty mech 22 papers 6th sem.pdf
 
ty 2018 atkt papers.pdf
ty 2018 atkt papers.pdfty 2018 atkt papers.pdf
ty 2018 atkt papers.pdf
 
P.P. PAPER.pdf
P.P. PAPER.pdfP.P. PAPER.pdf
P.P. PAPER.pdf
 
A.M.D. PAPER.pdf
A.M.D. PAPER.pdfA.M.D. PAPER.pdf
A.M.D. PAPER.pdf
 
theorem.pdf
theorem.pdftheorem.pdf
theorem.pdf
 

Recently uploaded

IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 

Recently uploaded (20)

IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 

mid point algorithm.pdf

  • 1. A Circle Drawing Algorithm • The equation for a circle is: • where r is the radius of the circle • So, we can write a simple circle drawing algorithm by solving the equation for y at unit x intervals using: 2 2 2 r y x = + 2 2 x r y − ± =
  • 2. Direct circle algorithm • Cartesian coordinates • Circle equation: ( x - xc )2 + ( y - yc )2 = r2 • Step along x axis from xc - r to xc + r and calculate y = yc ± √ r2 - ( x - xc )2
  • 3. Figure 6-11 Circle with center coordinates (xc , yc) and radius r .
  • 4. Figure 6-12 Upper half of a circle plotted with Equation 6-27 and with (xc , yc) = (0, 0).
  • 5. Eight-Way Symmetry • (y,x) (x,y) (x, -y) (y, -x) (-x, -y) (-y, -x) (-x,y) (-x, y) 2 R
  • 6. Mid-Point Circle Algorithm In the mid-point circle algorithm we use eight-way symmetry so only ever calculate the points for the top right eighth of a circle, and then use symmetry to get the rest of the points
  • 7. Mid-Point Circle Algorithm (cont…) (xk+1, yk) (xk+1, yk-1) (xk, yk) •Assume that we have just plotted point (xk, yk) •The next point is a choice between (xk+1, yk) and (xk+1, yk-1) •We would like to choose the point that is nearest to the actual circle
  • 8. Mid-Point Circle Algorithm •Let’s re-jig the equation of the circle slightly to give us: •The equation evaluates as follows: •By evaluating this function at the midpoint between the candidate pixels we can make our decision 2 2 2 ) , ( r y x y x fcirc − + =      > = < , 0 , 0 , 0 ) , ( y x fcirc boundary circle the inside is ) , ( if y x boundary circle on the is ) , ( if y x boundary circle the outside is ) , ( if y x
  • 9. Mid-Point Circle Algorithm • Assuming we have just plotted the pixel at (xk,yk) so we need to choose between (xk+1,yk) and (xk+1,yk-1) • Our decision variable can be defined as: • If pk < 0 the midpoint is inside the circle and the pixel at yk is closer to the circle • Otherwise the midpoint is outside and yk-1 is closer 2 2 2 ) 2 1 ( ) 1 ( ) 2 1 , 1 ( r y x y x f p k k k k circ k − − + + = − + =
  • 10. Mid-Point Circle Algorithm (cont…) • To ensure things are as efficient as possible we can do all of our calculations incrementally • First consider: or: where yk+1 is either yk or yk-1 depending on the sign of pk ( ) ( ) 2 2 1 2 1 1 1 2 1 ] 1 ) 1 [( 2 1 , 1 r y x y x f p k k k k circ k − − + + + = − + = + + + + 1 ) ( ) ( ) 1 ( 2 1 2 2 1 1 + − − − + + + = + + + k k k k k k k y y y y x p p
  • 11. Mid-Point Circle Algorithm (cont…) •The first decision variable is given as: •Then if pk < 0 then the next decision variable is given as: • If pk > 0 then the decision variable is: r r r r f p circ − = − − + = − = 4 5 ) 2 1 ( 1 ) 2 1 , 1 ( 2 2 0 1 2 1 1 + + = + + k k k x p p 1 2 1 2 1 1 + − + + = + + k k k k y x p p
  • 12. The Mid-Point Circle Algorithm • Input radius r and circle centre (xc, yc), then set the coordinates for the first point on the circumference of a circle centred on the origin as: • Calculate the initial value of the decision parameter as: • Starting with k = 0 at each position xk, perform the following test. If pk < 0, the next point along the circle centred on (0, 0) is (xk+1, yk) and: ) , 0 ( ) , ( 0 0 r y x = r p − = 4 5 0 1 2 1 1 + + = + + k k k x p p
  • 13. The Mid-Point Circle Algorithm • Otherwise the next point along the circle is (xk+1, yk- 1) and: 4. Determine symmetry points in the other seven octants 5. Move each calculated pixel position (x, y) onto the circular path centred at (xc, yc) to plot the coordinate values: 6. Repeat steps 3 to 5 until x >= y 1 1 1 2 1 2 + + + − + + = k k k k y x p p c x x x + = c y y y + =
  • 14. Mid-Point Circle Algorithm Summary – Eight-way symmetry can hugely reduce the work in drawing a circle – Moving in unit steps along the x axis at each point along the circle’s edge we need to choose between two possible y coordinates