Java Utililty Methods Float Number Clamp

List of utility methods to do Float Number Clamp

Description

The list of methods to do Float Number Clamp are organized into topic(s).

Method

floatclamp(float value, float min, float max)
clamp
return value < min ? min : value > max ? max : value;
floatclamp(float value, float min, float max)
Restricts a value to be within a specified range.
value = (value > max) ? max : value;
value = (value < min) ? min : value;
return value;
floatclamp(float value, float minimum, float maximum)
Assure that a value is between two other values.
return Math.max(Math.min(value, maximum), minimum);
floatclamp(float value, float minimum, float maximum)
Clamps the value to the specified range.
return (value < minimum ? minimum : (value > maximum ? maximum : value));
floatclamp(float x, float a, float b)
Clamp a value to an interval.
return (x < a) ? a : (x > b) ? b : x;
floatclamp(float x, float y, float z)
Returns middle value from all three
if (x > y) {
    float tmp = x;
    x = y;
    y = tmp;
return Math.max(x, Math.min(y, z));
floatclamp180(float r1, float r2)
clamp
return clamp180(r1, r2, 0);
floatclamp1f(float f)
clampf
if (f > 1f)
    return 1f;
if (f < -1f)
    return -1f;
return f;
floatclamp360(float dir)
clamp
float outDirAbs = Math.abs(dir);
float outDir;
if (outDirAbs > 360.0f) {
    if (outDirAbs > 720.0f) {
        outDir = dir % 360.0f;
    } else {
        outDir = (dir > 0.0f) ? dir - 360.0f : dir + 360.0f;
    outDirAbs = Math.abs(outDir);
} else {
    if (dir < 0.0f)
        outDir = dir + 360.0f;
    else
        outDir = dir;
return outDir;
floatclamp_float(float p_76131_0_, float p_76131_1_, float p_76131_2_)
Returns the value of the first parameter, clamped to be within the lower and upper limits given by the second and third parameters
return p_76131_0_ < p_76131_1_ ? p_76131_1_ : (p_76131_0_ > p_76131_2_ ? p_76131_2_ : p_76131_0_);