Esempio n. 1
0
 /// <summary>
 /// Compute whether or not two polygons are colliding based on whether or not the vertices of
 /// either are enclosed within the shape of the other. This is a simple means of detecting collisions
 /// that can fail if the two polygons are heavily overlapped in such a way that one protrudes through
 /// the other and out its opposing side without any vertices being enclosed.
 /// </summary>
 /// <param name="a">The first polygon.</param>
 /// <param name="b">The second polygon</param>
 /// <returns>True if the vertices collide; otherwise false.</returns>
 public static bool ArePolygonVerticesColliding(Polygon2D a, Polygon2D b)
 {
     return(a.points.Any(b.EnclosesPoint) || b.points.Any(a.EnclosesPoint));
 }
Esempio n. 2
0
 /// <summary>
 /// Test whether a point is enclosed within a polygon. Points on the polygon edges are not
 /// counted as contained within the polygon.
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public bool EnclosesPoint(Point2D p)
 {
     return(Polygon2D.IsPointInPolygon(p, this));
 }