Tuesday, November 10, 2015

CIRCLE-GENERATING ALGORITHMS



Midpoint circle Algorithm
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. Calculate the initial value of the decision parameter as P0=(5/4)-r
3. At each xk position, starting at k=0, perform the following test.
 If Pk<0 the next point along the circle centered on (0,0) is (xk+1,yk) and
Pk+1=Pk+2xk+1+1
Otherwise the next point along the circle is (xk+1,yk-1) and
Pk+1=Pk+2xk+1+1-2 yk+1 Where 2xk+1=2xk+2 and 2yk+1=2yk-2
4. Determine symmetry points in the other seven octants.
5. Move each calculated pixel position (x,y) onto the circular path centered at (xc,yc) and plot the coordinate values. x=x+xc y=y+yc 6. Repeat step 3 through 5 until x>=y.

No comments:

Post a Comment