private double CalculateConcaveRadius( int num_points, int skip )
{
// For really small numbers of points.
if ( num_points < 5 )
return 0.33f;
// Calculate angles to key points.
double dtheta = 2 * Math.PI / num_points;
double theta00 = -Math.PI / 2;
double theta01 = theta00 + dtheta * skip;
double theta10 = theta00 + dtheta;
double theta11 = theta10 - dtheta * skip;
// Find the key points.
PointF pt00 = new PointF(
( float )Math.Cos( theta00 ),
( float )Math.Sin( theta00 ) );
PointF pt01 = new PointF(
( float )Math.Cos( theta01 ),
( float )Math.Sin( theta01 ) );
PointF pt10 = new PointF(
( float )Math.Cos( theta10 ),
( float )Math.Sin( theta10 ) );
PointF pt11 = new PointF(
( float )Math.Cos( theta11 ),
( float )Math.Sin( theta11 ) );
// See where the segments connecting the points intersect.
bool lines_intersect, segments_intersect;
PointF intersection, close_p1, close_p2;
FindIntersection( pt00, pt01, pt10, pt11,
out lines_intersect, out segments_intersect,
out intersection, out close_p1, out close_p2 );
// Calculate the distance between the
// point of intersection and the center.
return Math.Sqrt(
intersection.X * intersection.X +
intersection.Y * intersection.Y );
}