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

Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
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
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
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
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
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
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
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
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
(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
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 

Recently uploaded (20)

Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
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...
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
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...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
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
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
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
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
(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...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 

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