Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all ??

+7 votes

Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all ??

0 votes

Use Mid Point Circle Algorithm

```
public static void DrawCircle(int x0, int y0, int radius)
{
int x = radius, y = 0;
int radiusError = 1-x;
while(x >= y)
{
DrawPixel(x + x0, y + y0);
DrawPixel(y + x0, x + y0);
DrawPixel(-x + x0, y + y0);
DrawPixel(-y + x0, x + y0);
DrawPixel(-x + x0, -y + y0);
DrawPixel(-y + x0, -x + y0);
DrawPixel(x + x0, -y + y0);
DrawPixel(y + x0, -x + y0);
y++;
if(radiusError<0)
radiusError+=2*y+1;
else
{
x--;
radiusError+=2*(y-x+1);
}
}
}
```

...