public class Mathematics
extends java.lang.Object
Constructor and Description |
---|
Mathematics() |
Modifier and Type | Method and Description |
---|---|
static double |
clamp(double x,
double a,
double b)
The method clamps the scalar x to range <a, b>.
|
static double |
clampBottom(double x,
double a)
The method clamps the scalar x to range <a, inf).
|
static double |
degToRad(double degrees) |
static double |
gauss(double x,
double sigma)
Method computes the Gaussian function.
|
static int |
getNextHighestPowerOfTwo(int x) |
static boolean |
isEven(int value)
The method checks id the value is even.
|
static boolean |
isPowerOfTwo(int value)
The method checks if the value is power of two.
|
static double |
mapLinear(double x,
double a1,
double a2,
double b1,
double b2)
Linear mapping the scalar x from range <a1, a2> to range <b1, b>
|
static double |
radToDeg(double radians) |
static double |
randFloat(double low,
double high)
The method generates random double value in the range <low, high>.
|
static double |
randFloatSpread(double range)
The method generates random double value in the interval
<-range/2, range/2>.
|
static int |
randInt(int low,
int high)
The method generates random integer value in the interval <low, high>.
|
static double |
random16()
The method generates random double value in the range <0, 1> with
16 bits of randomness (standard Math.random() creates repetitive
patterns when applied over larger space).
|
static double |
sign(double x)
This method returns a sign of the scalar x.
|
static double |
smootherstep(double x,
double min,
double max) |
static double |
smoothstep(double x,
double min,
double max)
http://en.wikipedia.org/wiki/Smoothstep
|
public static double clamp(double x, double a, double b)
x
- the scalar value for clampinga
- the start value of the rangeb
- the end value of the rangepublic static double clampBottom(double x, double a)
x
- the scalar value for clampinga
- the start value of the rangepublic static double mapLinear(double x, double a1, double a2, double b1, double b2)
x
- the scalar value for linear mappinga1
- the start value of the first rangea2
- the end value of the first rangeb1
- the start value of the last rangeb2
- the end value of the last rangepublic static double smoothstep(double x, double min, double max)
x
- min
- max
- public static double smootherstep(double x, double min, double max)
public static double random16()
public static int randInt(int low, int high)
low
- the start value of the interval.high
- the end value of the intervalpublic static double randFloat(double low, double high)
low
- the start value of the range.high
- the end value of the rangepublic static double randFloatSpread(double range)
range
- the value used to build the intervalpublic static double degToRad(double degrees)
public static double radToDeg(double radians)
public static boolean isPowerOfTwo(int value)
value
- the Integer valuepublic static int getNextHighestPowerOfTwo(int x)
public static boolean isEven(int value)
value
- the Integer valuepublic static double sign(double x)
x
- the scalar value for checking.public static double gauss(double x, double sigma)
x
- the input scalarsigma
- the Gaussian sigma parameter.