using System;
namespace Core.Common.Utils
{
public static class MathUtils
{
///
/// This method returns the clipped value of a value
/// given a valid value range.
///
/// A comparible object.
/// The value to be clipped.
/// Lowest allowed value (inclusive).
/// Highsest allowed value (inclusive).
/// The clipped value within the given validity range.
public static T ClipValue(T value, T min, T max) where T : IComparable
{
if (value.CompareTo(max) > 0)
{
return max;
}
if (value.CompareTo(min) < 0)
{
return min;
}
return value;
}
}
}