namespace Impostor.Api.Unity { public static class Mathf { /// /// Clamps the given value between the given minimum float and maximum float values. Returns the given value if it is within the min and max range. /// /// The floating point value to restrict inside the range defined by the min and max values. /// The minimum floating point value to compare against. /// The maximum floating point value to compare against. /// /// The float result between the min and max values. /// public static float Clamp(float value, float min, float max) { if (value < (double)min) { value = min; } else if (value > (double)max) { value = max; } return value; } /// /// Clamps value between 0 and 1 and returns value. /// /// Value. /// Clamped value. public static float Clamp01(float value) { if (value < 0.0) { return 0.0f; } return (double)value > 1.0 ? 1f : value; } /// /// Linearly interpolates between a and b by t. /// /// The start value. /// The end value. /// The interpolation value between the two floats. /// /// The interpolated float result between the two float values. /// public static float Lerp(float a, float b, float t) => a + ((b - a) * Clamp01(t)); } }