Mid
Point Circle Algorithm :
Begin:
Read (Xc,Yc) and r
P = 1 – r, x
= 0, y = r
while(X<=Y)
plot(X,Y)
X = X+1
If
(p<=0)
{
P=P+2X-1
}
else
{
Y=Y-1
P=P+2(X-Y)+1
}
end if
end of while
End
Function of Mid Point Circle :
void circlemidpoint(int xc,int yc,int r)
{
int x=0;
int y=r;
int p =1-r;
point( xc, yc,x,y);
while(x<y)
{
x++;
if(p<0)
p+=2*x+1;
else
{
y--;
p+=2*(x-y)+1;
}
point(xc,yc,x,y);
}
}
void point(int xc,int yc,int x,int y)
{
putpixel(xc+x,yc+y,58);
putpixel(xc+y,yc+x,58);
putpixel(xc-y,yc+x,58);
putpixel(xc-x,yc+y,58);
putpixel(xc+x,yc-y,58);
putpixel(xc-y,yc-x,58);
putpixel(xc+y,yc-x,58);
putpixel(xc-x,yc-y,58);
}
No comments:
Post a Comment