Modifier and Type | Field and Description |
---|---|
static float |
EPSILON
A small number.
|
static float |
HALF_PI
Pi times one half.
|
static float |
TAU
The circle constant, Tau (τ) http://tauday.com/
|
static float |
TWO_PI
Twice Pi.
|
Constructor and Description |
---|
MathUtil() |
Modifier and Type | Method and Description |
---|---|
static float |
angularDifference(float a1,
float a2)
Returns the (shortest) difference between two angles, assuming that both angles are in
[-pi, +pi].
|
static float |
angularDistance(float a1,
float a2)
Returns the (shortest) distance between two angles, assuming that both angles are in
[-pi, +pi].
|
static float |
clamp(float v,
float lower,
float upper)
Clamps a value to the range [lower, upper].
|
static boolean |
epsilonEquals(float v1,
float v2)
Determines whether two values are "close enough" to equal.
|
static float |
exponential(float random,
float mean)
Returns a random value according to the exponential distribution with the provided mean.
|
static int |
iceil(float v)
Returns the ceiling of v as an integer without calling the relatively expensive
Math.ceil(double) . |
static int |
ifloor(float v)
Returns the floor of v as an integer without calling the relatively expensive
Math.floor(double) . |
static boolean |
isWithin(float v,
float lower,
float upper)
Checks whether the value supplied is in [lower, upper].
|
static float |
lerp(float v1,
float v2,
float t)
Linearly interpolates between v1 and v2 by the parameter t.
|
static float |
lerpa(float a1,
float a2,
float t)
Linearly interpolates between two angles, taking the shortest path around the circle.
|
static float |
mirrorAngle(float a)
Returns the mirror angle of the specified angle (assumed to be in [-pi, +pi]).
|
static float |
normal(float normal,
float mean,
float stddev)
Returns a random value according to the normal distribution with the provided mean and
standard deviation.
|
static float |
normalizeAngle(float a)
Returns an angle in the range [-pi, pi).
|
static float |
normalizeAnglePositive(float a)
Returns an angle in the range [0, 2pi).
|
static int |
round(float v)
A cheaper version of
Math.round(float) that doesn't handle the special cases. |
static float |
roundNearest(float v,
float target)
Rounds a value to the nearest multiple of a target.
|
static void |
setToStringDecimalPlaces(int places)
Sets the number of decimal places to show when formatting values.
|
static String |
toString(float value)
Formats the supplied value, truncated to the currently configured number of decimal places.
|
static String |
toString(float value,
int decimalPlaces)
Formats the supplied floating point value, truncated to the given number of decimal places.
|
public static final float EPSILON
public static final float TAU
public static final float TWO_PI
public static final float HALF_PI
public static int round(float v)
Math.round(float)
that doesn't handle the special cases.public static int ifloor(float v)
Math.floor(double)
.public static int iceil(float v)
Math.ceil(double)
.public static float clamp(float v, float lower, float upper)
public static float roundNearest(float v, float target)
public static boolean isWithin(float v, float lower, float upper)
public static float normal(float normal, float mean, float stddev)
normal
- a normally distributed random value.mean
- the desired mean.stddev
- the desired standard deviation.public static float exponential(float random, float mean)
random
- a uniformly distributed random value.mean
- the desired mean.public static float lerpa(float a1, float a2, float t)
public static float lerp(float v1, float v2, float t)
public static boolean epsilonEquals(float v1, float v2)
public static float angularDistance(float a1, float a2)
public static float angularDifference(float a1, float a2)
public static float normalizeAngle(float a)
public static float normalizeAnglePositive(float a)
public static float mirrorAngle(float a)
public static void setToStringDecimalPlaces(int places)
public static String toString(float value)
public static String toString(float value, int decimalPlaces)
Copyright © 2017. All rights reserved.