Tuesday, September 10, 2013

Tagged Under:

Mid-Point Circle Drawing Algorithm

Share


Mid - Point Circle drawing Algorithm





Algorithm

1. Input radius (r) and center (Xc,Yc) and calculate the first point on the circumference of the circle centered on the origin as 
x=0; y=r
2. Calculate the initial value of the decision parameter as :
p=1.25-r;
3.
do
 {
  plot(x,y);
   if(p<0)
    { x=x+1;
     y=y;
     p=p+2*x+1;
    }
   else
    { x=x+1;
     y=y-1;
     p=p+2*x-2*y+1;
    }
 }
4.Determine symmetry points in other octants.
(cx + x, cy + y);
(cx - x, cy + y);
(cx + x, cy - y);
(cx - x, cy - y);
(cx + y, cy + x);
(cx - y, cy + x);
(cx + y, cy - x);
(cx - y, cy - x);
// Where (CX,CY) are co-ordinates of center of circle and (X,Y) are points to be plotted.

5.Stop

Check Implementation of this Algorithm in C .