0% found this document useful (0 votes)
64 views24 pages

Graphics 05 Mid-Point Circle

The document discusses algorithms for drawing circles, including their disadvantages and how the mid-point circle algorithm improves upon them. It explains that the mid-point circle algorithm uses eight-fold symmetry to only calculate points for one eighth of the circle. It provides the equation used to evaluate if a point is inside, on, or outside the circle boundary. It also explains how to compute the initial decision variable and how it is incremented during each iteration based on whether the next pixel is East or Southeast.

Uploaded by

Tanvir Alam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views24 pages

Graphics 05 Mid-Point Circle

The document discusses algorithms for drawing circles, including their disadvantages and how the mid-point circle algorithm improves upon them. It explains that the mid-point circle algorithm uses eight-fold symmetry to only calculate points for one eighth of the circle. It provides the equation used to evaluate if a point is inside, on, or outside the circle boundary. It also explains how to compute the initial decision variable and how it is incremented during each iteration based on whether the next pixel is East or Southeast.

Uploaded by

Tanvir Alam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

CSE- 4105

Mid point Circle drawing


Circle Generating Algorithms
• Circles and ellipses are common components in
many pictures.
• Circle generation routines are often included in
packages.
Circle Equations
• Polar form
x = rCos
y = rSin (r = radius of circle)

P=(rCos, rSin)
r rSin)

x
rCos)
Drawing a circle

 = 0°
while ( < 360°)
x = rCos
y = rSin
setPixel(x,y)
 =  + 1°
end while

Disadvantages
• To find a complete circle  varies from 0° to 360°
• The calculation of trigonometric functions is very slow.
Cartesian form
• Use Pythagoras theorem
r y
x2 + y2 = r2
• So, we can write a simple circle x
drawing algorithm by solving the y
equation for y at unit x intervals
using: 
P  x, r 2  x 2 
y r x 2 2
r y
x x
A Simple Circle Drawing Algorithm

y0  20 2  0 2  20

y1  20 2  12  20
y2  20 2  22  20

y19  20 2  19 2  6

y20  20  20  0
2 2
Circle algorithms
• Step through x-axis to determine y-values
Problems
• However, unsurprisingly this is not a brilliant solution!
• Firstly, the resulting circle has large gaps where the
slope approaches the vertical
• Secondly, the calculations are not very efficient
• The square (multiply) operations
• The square root operation – try really hard to avoid these!
• We need a more efficient, more accurate solution
Circle Algorithms
• Use 8-fold symmetry and only compute pixel positions
for the 45° sector.
• The first thing we can notice to make our circle drawing
algorithm more efficient is that circles centred at (0, 0) have
eight-way symmetry

(-x, y) (x, y)

(-y, x) (y, x)

R
2
(-y, -x) (y, -x)

(-x, -y) (x, -y)


Mid-Point Circle Algorithm
• Similarly to the case with lines, there is an incremental
algorithm for drawing circles – the 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
Mid-Point Circle Algorithm
Mid-Point Circle Algorithm
Mid-Point Circle Algorithm
• Let’s re-jig the equation of the circle slightly to give us:

f circ ( x, y)  x 2  y 2  r 2
• The equation evaluates as follows:

 0, if ( x, y) is inside the circle boundary



f circ ( x, y )  0, if ( x, y) is on the circle boundary
 0, if ( x, y) is outside the circle boundary

• By evaluating this function at the midpoint between the


candidate pixels we can make our decision
Mid-Point Circle Algorithm
Scan Conversion of Circles
• We need a decision variable D:

• If then M is below the arc, hence the E


pixel is closer to the line.
• If then M is above the arc, hence the SE
pixel is closer to the line.

1994 Foley/VanDam/Finer/Huges/Phillips ICG


Mid-Point Circle Algorithm

yk yk
midpoint midpoint

yk-1 yk-1

Fk < 0 Fk >= 0

yk+1 = yk yk+1 = yk - 1

Next pixel = (xk+1, yk) Next pixel = (xk+1, yk-1)


16
Case I: When E is next
Case I: When E is next
• What increment for computing a new D?
• Next midpoint is:

• Hence, increment by:


Pics/Math courtesy of Dave Mount @ UMD-CP
Case II: When SE is next
• What increment for computing a new D?
• Next midpoint is:

• Hence, increment by:


Scan Conversion of Circles
• How to compute the initial value of D:
• We start with x = 0 and y = R, so the first midpoint is at
x = 1, y = R-1/2:

(0,-R)

(R,0)

(0,R)
Algorithm
example

Use the mid-point circle algorithm to draw the circle centred at (2,-3) with radius 5

SL/iter x y d E SE
0 0 5 -4 √
1 1 5 -1 √
2 2 5 4 √
3 3 4 3 √
y!>x,
4 4 3 6 √ stop
iteration

considering circle center is at (2,-3)

=x+2 =y-3
2 2
3 2
4 2
5 1
6 0
Fig. 3.15, Fig. 3.16 and Fig. 3.18

Practice/Exercise:

Use the mid-point circle algorithm to draw the cir


cle centred at (2,-5) with radius 15

You might also like