Created
July 15, 2021 14:19
-
-
Save yanandrey/3db1589612f7bef815ba67c723b76112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool IsPointInPolygon(List<Location> poly, Location point) | |
{ | |
int i, j; | |
var c = false; | |
for (i = 0, j = poly.Count - 1; i < poly.Count; j = i++) | |
{ | |
if ((poly[i].Lt <= point.Lt && point.Lt < poly[j].Lt | |
|| poly[j].Lt <= point.Lt && point.Lt < poly[i].Lt) | |
&& point.Lg < (poly[j].Lg - poly[i].Lg) * (point.Lt - poly[i].Lt) | |
/ (poly[j].Lt - poly[i].Lt) + poly[i].Lg) | |
{ | |
c = !c; | |
} | |
} | |
return c; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment