Skip to content

Instantly share code, notes, and snippets.

@davidluzgouveia
davidluzgouveia / PointInsidePolygon.cs
Last active March 4, 2018 15:07
Point inside polygon with tolerance using ellipses as edges
public static bool Inside(IList<Vector2> polygon, Vector2 position, bool toleranceOnOutside = true)
{
Vector2 point = position;
const float epsilon = 0.5f;
bool inside = false;
// Must have 3 or more edges
if (polygon.Count < 3) return false;