I'm trying to figure out a way to check if a certain point is inside or outside a circle on an isometric map. I'm currently using the following method to draw the circle:
public static List<Coords> GetBrushCircleCoords(int x0, int y0, int radius)
{
List<Coords> coords = new List<Coords>();
int x = radius;
int y = 0;
int err = 0;
while (x >= y)
{
coords.Add(new Coords(x0 + x, y0 + y));
coords.Add(new Coords(x0 + y, y0 + x));
coords.Add(new Coords(x0 - y, y0 + x));
coords.Add(new Coords(x0 - x, y0 + y));
coords.Add(new Coords(x0 - x, y0 - y));
coords.Add(new Coords(x0 - y, y0 - x));
coords.Add(new Coords(x0 + y, y0 - x));
coords.Add(new Coords(x0 + x, y0 - y));
y += 1;
err += 1 + 2 * y;
if (2 * (err - x) + 1 > 0)
{
x -= 1;
err += 1 - 2 * x;
}
}
return coords;
}
And the approach I'm trying to determine if the point is inside the circle is basically taking the desired point, determine its distance to the center and checking if it's bigger than the radius with the following method:
public static int GetDistance(Coords _from, Coords _to)
{
return Math.Max(Math.Abs(_from.X - _to.X), Math.Abs(_from.Y - _to.Y));
}
However, it seems the GetDistance method isn't the best way to calculate this as the distance calculated by it is fairly shorter than the one used on the GetBrushCircleCoords. What would be the correct way of determining if a certain point is inside/outside this circle?