public final class MathUtil
extends java.lang.Object
MathUtil
class contains static methods for common calculations and
mathematical utilities.Modifier | Constructor and Description |
---|---|
private |
MathUtil()
MathUtil should not be instantiable. |
Modifier and Type | Method and Description |
---|---|
static double |
scaleToRange(double num,
double[] inputRange,
double[] outputRange)
Scales a number within some range to a corresponding position relative to another
range.
|
static double |
truncateToRange(double num,
double min,
double max)
Truncates the number to be only within a given range.
|
public static double scaleToRange(double num, double[] inputRange, double[] outputRange)
num
- the number to be scaledinputRange
- a two-element array representing the lowest and and highest
values, respectively, of the range to be scaled fromoutputRange
- a two-element array representing the lowest and and highest
values, respectively, of the range to be scaled topublic static double truncateToRange(double num, double min, double max)
num
- the number to scale.min
- the minimum of the range.max
- the maximum range.num
such that min <= num <= max
.