public class MathUtils
extends java.lang.Object
| Constructor and Description |
|---|
MathUtils() |
| Modifier and Type | Method and Description |
|---|---|
static double |
clamp(double value,
double min,
double max)
Test a value in specified range, returning minimum if it's below, and maximum if it's above
|
static float |
clamp(float value,
float min,
float max)
Test a value in specified range, returning minimum if it's below, and maximum if it's above
|
static double |
normalize(double x,
double dataLow,
double dataHigh,
double normalizedLow,
double normalizedHigh)
Scale a value from an arbitrary range to a normalized range.
|
static double |
wrap(double value,
double min,
double max)
Constrains value to the given range (including min, excluding max) via modular arithmetic.
|
public static double clamp(double value,
double min,
double max)
value - Value to testmin - Minimum value of rangemax - Maximum value of rangepublic static float clamp(float value,
float min,
float max)
value - Value to testmin - Minimum value of rangemax - Maximum value of rangepublic static double wrap(double value,
double min,
double max)
Same formula as used in Core GL (wrap.hpp) std::fmod((std::fmod((value - min), d) + d), d) + min;
value - Value to wrapmin - Minimum valuemax - Maximum valuepublic static double normalize(double x,
double dataLow,
double dataHigh,
double normalizedLow,
double normalizedHigh)
x - The value to be normalized.dataLow - lowest expected value from a data setdataHigh - highest expected value from a data setnormalizedLow - normalized lowest valuenormalizedHigh - normalized highest value