public override void GetLocalExtremePointWithoutMargin(ref Vector3 direction, out Vector3 extremePoint)
{
//Is it the tip of the cone?
float sinThetaSquared = radius * radius / (radius * radius + height * height);
//If d.Y * d.Y / d.LengthSquared >= sinthetaSquared
if (direction.Y > 0 && direction.Y * direction.Y >= direction.LengthSquared() * sinThetaSquared)
{
extremePoint = new Vector3(0, .75f * height, 0);
return;
}
//Is it a bottom edge of the cone?
float horizontalLengthSquared = direction.X * direction.X + direction.Z * direction.Z;
if (horizontalLengthSquared > Toolbox.Epsilon)
{
var radOverSigma = radius / Math.Sqrt(horizontalLengthSquared);
extremePoint = new Vector3((float)(radOverSigma * direction.X), -.25f * height, (float)(radOverSigma * direction.Z));
}
else // It's pointing almost straight down...
extremePoint = new Vector3(0, -.25f * height, 0);
}