List of utility methods to do Float Number Clamp
byte | clampRoundByte(float in) Clamps and rounds a number to the range supported by byte data type. return (in > 0xFF ? (byte) 0xFF : (in >= 0 ? (byte) (in + 0.5F) : (byte) 0)); |
float | clampToMinusOneToOne(float value) Clamps the given value to the -1..1 range. if (value < -1) { value = -1; if (value > 1) { value = 1; return value; |
float | clampToPositiveNonZero(float value) Clamps the value to a positive non-zero value. return Math.max(Float.MIN_VALUE, value);
|
float | clampTrigo(float value, float min, float max) Clamp the given value to fit between the min and max values according to a trigonometric-like heuristic. if (Float.isNaN(max)) { return Float.NaN; if (Float.isNaN(min)) { if (value > max) return max - Float.MAX_VALUE + value; } else { assert (min <= max); ... |
float | clampWithMod(float parFloat, float parMax) clamp With Mod return (parFloat + parMax) % parMax;
|
float | clampYaw(float yaw) clamp Yaw while (yaw < -180.0F) { yaw += 360.0F; while (yaw >= 180.0F) { yaw -= 360.0F; return yaw; |
float | clampYaw(float yaw) Ensure a yaw angle is between -180 and 180 degrees. while (yaw > 180f) yaw -= 360f; while (yaw < -180f) yaw += 360f; return yaw; |
float | clampZero_float(float value, float max) clamp Zerfloat return clampFloat(value, 0f, max);
|