Professional Documents
Culture Documents
Midpoint Circle
Midpoint Circle
x2 + y2 = r 2
• where r is the radius of the circle
y=± r −x 2 2
Direct circle algorithm
• Cartesian coordinates
• Circle equation:
( x - xc )2 + ( y - yc )2 = r2
(-x, y) (y,x)
(-x,y) (x,y)
R
2
(-y, -x) (x, -y)
pk +1 = pk + 2( xk + 1) + ( yk2+1 − yk2 ) − ( yk +1 − yk ) + 1
Mid-Point Circle Algorithm (cont…)
•The first decision variable is given as:
p0 = f circ (1, r − 1 )
2
= 1 + (r − 1 ) 2 − r 2
2
= 5 −r
4
pk +1 = pk + 2 xk +1 + 1 − 2 yk + 1
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:
( x0 , y0 ) = (0, r )
• Calculate the initial value of the decision parameter as:
p0 = 5 − r
4
• 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:
pk +1 = pk + 2 xk +1 + 1
The Mid-Point Circle Algorithm
• Otherwise the next point along the circle is (xk+1, yk-
1) and:
pk +1 = pk + 2 xk +1 + 1 − 2 yk +1