org.diirt.graphene

## Class MathUtil

• ```public class MathUtil
extends Object```
Author:
carcassi
• ### Constructor Summary

Constructors
Constructor and Description
`MathUtil()`
• ### Method Summary

All Methods
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.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### MathUtil

`public MathUtil()`
• ### Method Detail

• #### orderOf

`public static int orderOf(double value)`
Returns the base 10 logarithm of the given value, to the nearest integer value.

Uses Math.log10(double a)

Special cases: (from Math.log10(double a))

• If the argument is NaN or less than zero, then the result is NaN.
• If the argument is positive infinity, then the result is positive infinity.
• If the argument is positive zero or negative zero, then the result is negative infinity.
• If the argument is equal to 10n for integer n, then the result is n
Parameters:
`value` - double
Returns:
truncated base 10 logarithm of the given value.
• #### normalize

```public 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.
Parameters:
`value` - - number between min and max, inclusive.
`min` - - lowest number in range.
`max` - - highest number in range.
Returns:
`double` from 0 to 1, inclusive.
• #### scale

```public 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.
Parameters:
`value` - - number between min and max, inclusive.
`min` - - lowest number in range.
`max` - - highest number in range.
`newWidth` - - scalar to multiply the ratio by.
Returns:
`double` from 0 to newWidth, inclusive.

Copyright © 2015. All rights reserved.