public static class MathUtility
{
//-------------------------------------------------------------------------------------
///
/// Same as System.Math.Acos but if angle is out of range, the result is clamped.
///
/// Input angle.
/// Acos the angle.
//-------------------------------------------------------------------------------------
public static float SafeAcos(float angle)
{
if(angle <= -1.0f)
{
return (float) (System.Math.PI);
}
if(angle >= 1.0f)
{
return 0.0f;
}
return (float) System.Math.Acos(angle);
}
}