namespace LinearAlgebra {
///
/// Float number utilities
///
public class Float {
///
/// The precision of float numbers
///
public const float epsilon = 1E-05f;
///
/// The square of the float number precision
///
public const float sqrEpsilon = 1e-10f;
///
/// Clamp the value between the given minimum and maximum values
///
/// The value to clamp
/// The minimum value
/// The maximum value
/// The clamped value
public static float Clamp(float f, float min, float max) {
if (f < min)
return min;
if (f > max)
return max;
return f;
}
///
/// Clamp the value between to the interval [0..1]
///
/// The value to clamp
/// The clamped value
public static float Clamp01(float f) {
return Clamp(f, 0, 1);
}
}
}