SlideShare a Scribd company logo
7
Most read
9
Most read
13
Most read
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

PPTX
Projection In Computer Graphics
PPTX
3 d display methods
PPTX
Mid point circle algorithm
PPTX
Bresenham circle
PPTX
Mid-Point Cirle Drawing Algorithm
PPTX
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
PPT
Midpoint circle algo
PPTX
Back face detection
Projection In Computer Graphics
3 d display methods
Mid point circle algorithm
Bresenham circle
Mid-Point Cirle Drawing Algorithm
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
Midpoint circle algo
Back face detection

What's hot (20)

PPTX
Clipping in Computer Graphics
PPTX
Computer graphics LINE DRAWING algorithm.pptx
PPT
Circle drawing algo.
PPT
Ellipses drawing algo.
PPT
Liang barsky Line Clipping Algorithm
PPT
2 d geometric transformations
PPT
Polygon clipping
PPT
2D transformation (Computer Graphics)
PPTX
Polygon filling algorithm
PDF
Unit 3
PPT
Polygon filling
PPTX
2D viewing & clipping
PPTX
Output primitives in Computer Graphics
PPTX
3D transformation in computer graphics
PPT
Visible surface detection in computer graphic
PDF
Computer Graphics - Output Primitive
PPTX
BRESENHAM’S LINE DRAWING ALGORITHM
PPTX
Bresenham's line drawing algorithm
PPTX
Introduction to computer graphics
PPTX
Attributes of output primitives( curve attributes & area fill attributes)
Clipping in Computer Graphics
Computer graphics LINE DRAWING algorithm.pptx
Circle drawing algo.
Ellipses drawing algo.
Liang barsky Line Clipping Algorithm
2 d geometric transformations
Polygon clipping
2D transformation (Computer Graphics)
Polygon filling algorithm
Unit 3
Polygon filling
2D viewing & clipping
Output primitives in Computer Graphics
3D transformation in computer graphics
Visible surface detection in computer graphic
Computer Graphics - Output Primitive
BRESENHAM’S LINE DRAWING ALGORITHM
Bresenham's line drawing algorithm
Introduction to computer graphics
Attributes of output primitives( curve attributes & area fill attributes)
Ad

Similar to mid point algorithm.pdf (20)

PPT
2.circle
PPT
Computer_Graphics_circle_drawing_techniq.ppt
PPT
10994479.ppt
PPTX
L-6 (Circle Drawing Algorithm Computer graphics).pptx
PPTX
Bresenham-Circle-drawing-algorithm, Midpoint Circle Drawing Algorithm
PPTX
Circle algorithm
PPTX
Algorithm.pptx
PPTX
Computer graphics
PPTX
PPT_14.pptx
PPTX
Lec05 circle ellipse
PPT
Graphics6 bresenham circlesandpolygons
PPT
Graphics6 bresenham circlesandpolygons
PPT
Shape drawing algs
PPT
2.Line,circle drawing.ppt line circlw drawing algorith
PPTX
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
PPT
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
PPT
Lines and curves algorithms
PPTX
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
PDF
10CSL67 CG LAB PROGRAM 6
PDF
Bresenhamcircle derivation
2.circle
Computer_Graphics_circle_drawing_techniq.ppt
10994479.ppt
L-6 (Circle Drawing Algorithm Computer graphics).pptx
Bresenham-Circle-drawing-algorithm, Midpoint Circle Drawing Algorithm
Circle algorithm
Algorithm.pptx
Computer graphics
PPT_14.pptx
Lec05 circle ellipse
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Shape drawing algs
2.Line,circle drawing.ppt line circlw drawing algorith
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
Lines and curves algorithms
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
10CSL67 CG LAB PROGRAM 6
Bresenhamcircle derivation
Ad

More from MehulMunshi3 (12)

PDF
Ch-3--Product_Design.pdf
PDF
Intro_to_OR.pdf
PDF
Ch-4--Manufacturing_Process_Selection_and_Design.pdf
PDF
Synthetic Curves.pdf
PDF
2D Translation.pdf
PDF
SUPER ALLOYS_1.pdf
PDF
SUPER ALLOYS.pdf
PDF
ty mech 22 papers 6th sem.pdf
PDF
ty 2018 atkt papers.pdf
PDF
P.P. PAPER.pdf
PDF
A.M.D. PAPER.pdf
PDF
theorem.pdf
Ch-3--Product_Design.pdf
Intro_to_OR.pdf
Ch-4--Manufacturing_Process_Selection_and_Design.pdf
Synthetic Curves.pdf
2D Translation.pdf
SUPER ALLOYS_1.pdf
SUPER ALLOYS.pdf
ty mech 22 papers 6th sem.pdf
ty 2018 atkt papers.pdf
P.P. PAPER.pdf
A.M.D. PAPER.pdf
theorem.pdf

Recently uploaded (20)

PDF
PPT on Performance Review to get promotions
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Sustainable Sites - Green Building Construction
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Geodesy 1.pptx...............................................
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT on Performance Review to get promotions
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Sustainable Sites - Green Building Construction
CYBER-CRIMES AND SECURITY A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Structs to JSON How Go Powers REST APIs.pdf
OOP with Java - Java Introduction (Basics)
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Geodesy 1.pptx...............................................
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
Arduino robotics embedded978-1-4302-3184-4.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CH1 Production IntroductoryConcepts.pptx
Lesson 3_Tessellation.pptx finite Mathematics
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.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