bool distanceToHullAcceptable( Vertices polygon, Vector2 point, bool higherDetail )
{
if( polygon == null )
throw new ArgumentNullException( nameof( polygon ), "'polygon' can't be null." );
if( polygon.Count < 3 )
throw new ArgumentException( "'polygon.Count' can't be less then 3." );
Vector2 edgeVertex2 = polygon[polygon.Count - 1];
Vector2 edgeVertex1;
if(higherDetail)
{
for( int i = 0; i < polygon.Count; i++ )
{
edgeVertex1 = polygon[i];
if( LineTools.distanceBetweenPointAndLineSegment( ref point, ref edgeVertex1, ref edgeVertex2 ) <= _hullTolerance || Vector2.Distance( point, edgeVertex1 ) <= _hullTolerance )
return false;
edgeVertex2 = polygon[i];
}
return true;
}
else
{
for( int i = 0; i < polygon.Count; i++ )
{
edgeVertex1 = polygon[i];
if( LineTools.distanceBetweenPointAndLineSegment( ref point, ref edgeVertex1, ref edgeVertex2 ) <= _hullTolerance )
return false;
edgeVertex2 = polygon[i];
}
return true;
}
}