Skip to content

Commit

Permalink
Refactoring - renamed IsInPolygon -> InPolygon
Browse files Browse the repository at this point in the history
  • Loading branch information
madddmax committed Aug 8, 2019
1 parent c95fba3 commit 798dfab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions Domain/Point.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ public Point(int x, int y)
Y = y;
}

public static bool IsInPolygon(List<Point> poly, Point pnt)
public static bool InPolygon(List<Point> polygon, Point pnt)
{
int i, j;
int nvert = poly.Count;
bool c = false;
for (i = 0, j = nvert - 1; i < nvert; j = i++)
for (int i = 0, j = polygon.Count - 1; i < polygon.Count; j = i++)
{
if (((poly[i].Y > pnt.Y) != (poly[j].Y > pnt.Y)) &&
(pnt.X < (poly[j].X - poly[i].X) * (pnt.Y - poly[i].Y) / (poly[j].Y - poly[i].Y) + poly[i].X))
if (((polygon[i].Y > pnt.Y) != (polygon[j].Y > pnt.Y)) &&
(pnt.X < (polygon[j].X - polygon[i].X) * (pnt.Y - polygon[i].Y) / (polygon[j].Y - polygon[i].Y) +
polygon[i].X))
{
c = !c;
}
}
return c;
}
Expand Down
2 changes: 1 addition & 1 deletion Domain/Simulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static Player GetNext(Player my, string direction, int depth)
{
var point = new Point(i, j);
if (!MyTerritory.Contains(point) &&
Point.IsInPolygon(myNext.Lines.ToList(), point))
Point.InPolygon(myNext.Lines.ToList(), point))
{
captured.Add(point);
}
Expand Down

0 comments on commit 798dfab

Please sign in to comment.