0% found this document useful (0 votes)
71 views23 pages

Graphics 05 Mid-Point Circle SC

Here are the steps to draw the circle using the mid-point circle algorithm: 1. Set x = 0, y = 15 2. Compute the initial decision parameter D = (15)2 + (0)2 - (15-1)2 = 31 3. Plot the pixel (0,15) 4. Increment x to 1 5. Compute the new decision parameter D' = D - 2y + 1 = 31 - 30 + 1 = 2 6. Since D' < 0, plot the pixel (1,14) 7. Increment x and repeat steps 4-6, tracking y as it increments/decrements based on the sign of D' 8. Continue

Uploaded by

Developers torch
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)
71 views23 pages

Graphics 05 Mid-Point Circle SC

Here are the steps to draw the circle using the mid-point circle algorithm: 1. Set x = 0, y = 15 2. Compute the initial decision parameter D = (15)2 + (0)2 - (15-1)2 = 31 3. Plot the pixel (0,15) 4. Increment x to 1 5. Compute the new decision parameter D' = D - 2y + 1 = 31 - 30 + 1 = 2 6. Since D' < 0, plot the pixel (1,14) 7. Increment x and repeat steps 4-6, tracking y as it increments/decrements based on the sign of D' 8. Continue

Uploaded by

Developers torch
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/ 23

CSE- 4105

Mid point Circle


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
Mid-Point Circle Algorithm
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
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