public static bool PointInPolygon(Polygon2 poly, Vector2 point) { var ls = new LineSegment2() { A = point, B = new Vector2() { X = poly.BoundingBox.Item1.X, Y = point.Y } }; var iCount = (from x in poly.Segments where LineSegment2.Intersection(ls, x) != null select x).Count() % 2; return iCount > 0; }
public static bool PolygonInPolygon(Polygon2 A, Polygon2 B) { foreach (var p in A.Points) { if (PointInPolygon(B, p)) return true; } return false; }