Package com.trimblemaps.mapsdk.utils
Class MathUtils
java.lang.Object
com.trimblemaps.mapsdk.utils.MathUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleclamp(double value, double min, double max) Test a value in specified range, returning minimum if it's below, and maximum if it's abovestatic floatclamp(float value, float min, float max) Test a value in specified range, returning minimum if it's below, and maximum if it's abovestatic doublenormalize(double x, double dataLow, double dataHigh, double normalizedLow, double normalizedHigh) Scale a value from an arbitrary range to a normalized range.static doublewrap(double value, double min, double max) Constrains value to the given range (including min, excluding max) via modular arithmetic.
-
Constructor Details
-
MathUtils
public MathUtils()
-
-
Method Details
-
clamp
public 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- Parameters:
value- Value to testmin- Minimum value of rangemax- Maximum value of range- Returns:
- value if it's between min and max, min if it's below, max if it's above
-
clamp
public 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- Parameters:
value- Value to testmin- Minimum value of rangemax- Maximum value of range- Returns:
- value if it's between min and max, min if it's below, max if it's above
-
wrap
public static double wrap(double value, double min, double max) Constrains value to the given range (including min, excluding max) via modular arithmetic.Same formula as used in Core GL (wrap.hpp) std::fmod((std::fmod((value - min), d) + d), d) + min;
- Parameters:
value- Value to wrapmin- Minimum valuemax- Maximum value- Returns:
- Wrapped value
-
normalize
public static double normalize(double x, double dataLow, double dataHigh, double normalizedLow, double normalizedHigh) Scale a value from an arbitrary range to a normalized range.- Parameters:
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- Returns:
- The result of the normalization.
-