public class MathUtil extends Object
| Constructor and Description |
|---|
MathUtil() |
| Modifier and Type | Method and Description |
|---|---|
static double |
normalize(double value,
double min,
double max)
Returns the ratio of the given value to the total range as a
double between 0 and 1. |
static int |
orderOf(double value)
Returns the base 10 logarithm of the given value, to the nearest integer value.
|
static double |
scale(double value,
double min,
double max,
double newWidth)
Returns the ratio of the given value to the total range as a
double between 0 and 1, multiplied by newWidth. |
public static int orderOf(double value)
Uses Math.log10(double a)
Special cases: (from Math.log10(double a))
value - doublepublic static double normalize(double value,
double min,
double max)
double between 0 and 1.value - - number between min and max, inclusive.min - - lowest number in range.max - - highest number in range.double from 0 to 1, inclusive.public static double scale(double value,
double min,
double max,
double newWidth)
double between 0 and 1, multiplied by newWidth.value - - number between min and max, inclusive.min - - lowest number in range.max - - highest number in range.newWidth - - scalar to multiply the ratio by.double from 0 to newWidth, inclusive.Copyright © 2015. All rights reserved.