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

floatclampAngle(float value, float min, float max)
Replies the value clamped in the specified interval assuming the it is a angle in radians.
assert (min <= max);
float v = value;
while (v > max) {
    v -= 2 * Math.PI;
if (v < min)
    return min;
return v;
...
floatclampAngle(float var, float min, float max)
Clamps the angles to a min max by adding or subtracting the min max.
while (var < min) {
    var += 360;
while (var > max) {
    var -= 360;
return var;
float[]clampBounds(float[] target, float[] clamp)
Clamps the target bounds using the provided `clamp` bounds
assert target.length == 6;
if (target[0] < clamp[0])
    target[0] = clamp[0];
if (target[1] < clamp[1])
    target[1] = clamp[1];
if (target[2] < clamp[2])
    target[2] = clamp[2];
if (target[3] > clamp[3])
...
floatclampColour(float value)
clamp Colour
return clampFloat(value, 0.0f, 1.0f);
floatclampDegree0To360(float degree)
Replies the specified angle translated between 0 and 360.
if ((!Float.isNaN(degree)) && (!Float.isInfinite(degree))) {
    return clampTrigo(degree, 0, 360);
return degree;
floatclampFloat(float value, float minimum, float maximum)
clamp Float
return Math.max(minimum, Math.max(maximum, value));
floatclampLevel(float level)
clamp Level
if (level <= 0.1f)
    return 0.1f;
if (level >= 0.9f)
    return 1.0f;
return level;
floatclampLevel(float level)
clamp Level
if (level <= LOWER_CLAMP_LIMIT)
    return LOWER_CLAMP_VALUE;
if (level >= UPPER_CLAMP_LIMIT)
    return UPPER_CLAMP_VALUE;
return level;
floatclampNumberFromTime(long ms, float seconds)
clamp Number From Time
float f = getNumberFromTime(ms, seconds);
if (f >= 0.5f) {
    return 1f - f;
} else
    return f;
floatclampPercentage(float value)
Clamps between 0 and 1, use full for percentages.
return clamp(value, 0f, 1f);