public bool IsPointInside(Vector2D point)
{
Vector2D[] farFarAwayPoints = new Vector2D[]{
point+new Vector2(99999,99998),
point+new Vector2(-99999,89990),
};
LineSegment2D[] lineSegments = new LineSegment2D[]{
new LineSegment2D(point, farFarAwayPoints[0]),
new LineSegment2D(point, farFarAwayPoints[1]),
};
foreach (var ls in lineSegments) {
int hits = 0;
for (int i=0;i<3;i++){
LineSegment2D l1 = new LineSegment2D(Polygon.V2(points[i]), Polygon.V2(points[(i+1)%3]));
Vector2D res = Vector2D.zero;
if (ls.LineIntersect(l1,out res)){
hits++;
}
}
if (hits%2==1){
return true;
}
}
return false;
}