Midpoint Circle Algorithm
Midpoint Circle Algorithm
ALGORITHM
DEFINATION
The midpoint circle algorithm is an algorithm
used to determine the points needed for drawing a
circle.
At each step, the path is extended by choosing
the adjacent pixel which satisfies but
maximizes .
We only need to calculate the values on the
border of the circle in the first octant. The other
values may be determined by symmetry.
Assume a circle of radius r with center at (h,k)
The first thing we can notice to make our circle
drawing algorithm more efficient is that circles centred at
(h,k) have eight-way symmetry
Thus,
fcircle(x,y) < 0 if (x,y) is inside the circle boundary
fcircle(x,y) = 0 if (x,y) is on the circle boundary
fcircle(x,y) > 0 if (x,y) is outside the circle boundary.
yk X2+y2-r2=0
Yk-1 Midpoint between candidate
pixels at sampling position xk+1
Midpoint xk xk+1 Xk+3 along a circular path
1: Input radius r and circle center (xc,yc) and obtain the first point on
the circumference of the circle centered on the origin as (x0,y0) = (0,r)
2 2 2
x +y -r =0 x=y
x
y
x
Use 8-fold symmetry and only compute pixel
positions for the 45° sector.
(-x, y) (x, y)
(-y, x) (y, x)
45°