diff --git a/src/Math/MathHelper.cs b/src/Math/MathHelper.cs index e7f7a568..a4477a2f 100644 --- a/src/Math/MathHelper.cs +++ b/src/Math/MathHelper.cs @@ -160,6 +160,26 @@ namespace MoonWorks.Math return value; } + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// + /// The minimum value. If value is less than min, min + /// will be returned. + /// + /// + /// The maximum value. If value is greater than max, max + /// will be returned. + /// + /// The clamped value. + public static int Clamp(int value, int min, int max) + { + value = (value > max) ? max : value; + value = (value < min) ? min : value; + return value; + } + /// /// Calculates the absolute value of the difference of two values. /// @@ -400,27 +420,6 @@ namespace MoonWorks.Math #region Internal Static Methods - // FIXME: This could be an extension! ClampIntEXT? -flibit - /// - /// Restricts a value to be within a specified range. - /// - /// The value to clamp. - /// - /// The minimum value. If value is less than min, min - /// will be returned. - /// - /// - /// The maximum value. If value is greater than max, max - /// will be returned. - /// - /// The clamped value. - internal static int Clamp(int value, int min, int max) - { - value = (value > max) ? max : value; - value = (value < min) ? min : value; - return value; - } - internal static bool WithinEpsilon(float floatA, float floatB) { return System.Math.Abs(floatA - floatB) < MachineEpsilonFloat;