public final class Maths extends Object
| Modifier and Type | Field and Description |
|---|---|
static double |
E
mathematical constant e
|
static double |
HALF_PI |
static double |
PI
Mathematical constant Pi = 3.1415926...
|
static double |
QUARTER_PI |
static double |
ROOT_THREE |
static double |
ROOT_TWO |
static double |
TAU
Mathematical constant Tau = 2 * Pi
|
static double |
TWO_PI |
| Constructor and Description |
|---|
Maths() |
| Modifier and Type | Method and Description |
|---|---|
static double |
bound(double v,
double min,
double max)
Bound a value within a given range
|
static float |
bound(float v,
float min,
float max)
Bound a value within a given range
|
static int |
bound(int v,
int min,
int max)
Bound a value within a given range
|
static int |
clampToInteger(double value,
int min,
int max)
Clamp a double value to an integer range
|
static int |
clampToInteger(float value,
int min,
int max)
Clamp a float value to an integer range
|
static double |
frac(double a)
Return the (always non-negative) fractional part of a number
|
static float |
frac(float a)
Return the (always non-negative) fractional part of a number
|
static double |
inverseLogistic(double y) |
static double |
lerp(double t,
double a,
double b)
Linear interpolation between a and b
|
static double |
logistic(double x)
Standard logistic function
|
static double |
logisticDerivative(double x) |
static double |
max(double a,
double b,
double c)
Return the maximum of three values
|
static float |
max(float a,
float b)
Return the maximum of two numbers
|
static float |
max(float a,
float b,
float c)
Return the maximum of three values
|
static float |
max(float a,
float b,
float c,
float d)
Return the maximum of four values
|
static int |
max(int a,
int b)
Return the maximum of two numbers
|
static int |
max(int a,
int b,
int c)
Return the maximum of three numbers
|
static float |
middle(float a,
float b,
float c)
Return the middle value of 3 numbers
Can use faster "bound" method if first and last parameters are in order
|
static int |
middle(int a,
int b,
int c)
Return the middle value of 3 numbers
Can use faster "bound" method if first and last parameters are in order
|
static double |
min(double a,
double b,
double c)
Return the minimum of three values
|
static float |
min(float a,
float b)
Return the minimum of two numbers
|
static float |
min(float a,
float b,
float c)
Return the minimum of three values
|
static float |
min(float a,
float b,
float c,
float d)
Return the minimum of four values
|
static int |
min(int a,
int b)
Return the minimum of two numbers
|
static int |
min(int a,
int b,
int c)
Return the minimum of three numbers
|
static double |
mod(double num,
double div)
Double mod function with fractional divisor
|
static int |
mod(int number,
int divisor)
Integer modulus function
|
static int |
modPower32Bit(int x,
int pow)
Returns (x^pow) mod (2^32) as an int
|
static boolean |
notNearZero(double x)
Tests whether a value is near zero, to a default tolerance level
|
static long |
quantize(long increase,
long boundary,
long base)
Detects the number of times that boundary is passed when adding increase to base
|
static int |
roundDown(double x)
Rounds down (integer floor) of a double value
|
static int |
roundDown(float x)
Round down to next smallest integer (towards negative infinity)
|
static int |
roundUp(double x)
Round up to next integer
|
static int |
roundUp(float x)
Round up to next integer
|
static int |
roundUp(Number x)
Round up to next integer
|
static int |
sign(double x)
Return the sign of a double value
|
static int |
sign(float x)
Return the sign of a float value
|
static int |
sign(int a)
Return the sign of an int value
|
static int |
sign(long a)
Return the sign of a long value
|
static double |
softMaximum(double x,
double y)
Soft maximum function
|
static double |
softplus(double x) |
static double |
sqrt(double a) |
static float |
sqrt(float a) |
static int |
square(byte b)
Return the square of a number
|
static double |
square(double x)
Return the square of a number
|
static float |
square(float x)
Return the square of a number
|
static int |
square(int x)
Return the square of a number
|
static double |
tanhDerivative(double x) |
static double |
tanhScaled(double x) |
static double |
tanhScaledDerivative(double x) |
static double |
triangleWave(double x)
Triangle wave with wavelength 1.0, and range 0.0 - 1.0
|
public static final double ROOT_TWO
public static final double ROOT_THREE
public static final double E
public static final double PI
public static final double TWO_PI
public static final double TAU
public static final double HALF_PI
public static final double QUARTER_PI
public static float sqrt(float a)
public static double sqrt(double a)
public static int clampToInteger(double value,
int min,
int max)
public static int clampToInteger(float value,
int min,
int max)
public static final double lerp(double t,
double a,
double b)
public static int middle(int a,
int b,
int c)
public static float middle(float a,
float b,
float c)
public static int sign(double x)
public static int sign(float x)
public static final int sign(int a)
public static int sign(long a)
public static int mod(int number,
int divisor)
n - numberd - divisorpublic static long quantize(long increase,
long boundary,
long base)
increase - boundary - base - public static double min(double a,
double b,
double c)
public static double max(double a,
double b,
double c)
public static float min(float a,
float b,
float c)
public static float max(float a,
float b,
float c)
public static final float min(float a,
float b,
float c,
float d)
public static final float max(float a,
float b,
float c,
float d)
public static int min(int a,
int b)
public static int max(int a,
int b)
public static float min(float a,
float b)
public static float max(float a,
float b)
public static int min(int a,
int b,
int c)
public static int max(int a,
int b,
int c)
public static double logistic(double x)
x - public static double softplus(double x)
public static double tanhScaled(double x)
public static double tanhScaledDerivative(double x)
public static double inverseLogistic(double y)
public static double logisticDerivative(double x)
public static double tanhDerivative(double x)
public static float frac(float a)
public static double frac(double a)
public static int square(byte b)
public static int square(int x)
public static float square(float x)
public static double square(double x)
public static int roundUp(double x)
public static int roundUp(Number x)
public static int roundUp(float x)
public static int roundDown(double x)
public static int roundDown(float x)
public static double softMaximum(double x,
double y)
public static final double bound(double v,
double min,
double max)
public static final float bound(float v,
float min,
float max)
public static final int bound(int v,
int min,
int max)
public static int modPower32Bit(int x,
int pow)
public static boolean notNearZero(double x)
public static double mod(double num,
double div)
public static double triangleWave(double x)
Copyright © 2013. All Rights Reserved.