public final class MathF
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static float |
EPSILON
An epsilon value.
|
static float |
PI
A
float representation of pi. |
static float |
PI_DIVIDED_BY_FOUR
A
float representation of pi divided by 4.0F . |
static float |
PI_DIVIDED_BY_TWO
A
float representation of pi divided by 2.0F . |
static float |
PI_MULTIPLIED_BY_TWO
A
float representation of pi multiplied by 2.0F . |
static float |
PI_RECIPROCAL
A
float representation of the reciprocal of pi. |
Modifier and Type | Method and Description |
---|---|
static float |
abs(float value)
Returns the absolute version of
value . |
static int |
abs(int value)
Returns the absolute version of
value . |
static float |
acos(float value)
Returns the arc cosine of
value . |
static float |
asin(float value)
Returns the arc sine of
value . |
static float |
atan(float value)
Returns the arc tangent of
value . |
static float |
atan2(float y,
float x)
Returns the theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.
|
static float |
cos(float angle)
Returns the trigonometric cosine of
angle . |
static boolean |
equals(float a,
float b)
Compares
a and b for equality. |
static float |
exp(float exponent)
Returns Euler's number
e raised to the power of exponent . |
static float |
floor(float value)
Returns the largest (closest to positive infinity)
float value that is less than or equal to value and is equal to a mathematical integer. |
static float |
max(float a,
float b)
Returns the greater value of
a and b . |
static float |
max(float a,
float b,
float c)
Returns the greater value of
a , b and c . |
static int |
max(int a,
int b)
Returns the greater value of
a and b . |
static float |
min(float a,
float b)
Returns the smaller value of
a and b . |
static float |
min(float a,
float b,
float c)
Returns the smaller value of
a , b and c . |
static int |
min(int a,
int b)
Returns the smaller value of
a and b . |
static float |
modulo(float value)
Returns the value that is computed as
value - floor(value) . |
static float |
nextFloat()
Returns a pseudorandom
float value between 0.0F (inclusive) and 1.0F (exclusive). |
static float |
pow(float base,
float exponent)
Returns
base raised to the power of exponent . |
static float |
saturate(float value)
Returns a saturated (or clamped) value based on
value . |
static float |
saturate(float value,
float minimum,
float maximum)
Returns a saturated (or clamped) value based on
value . |
static int |
saturate(int value)
Returns a saturated (or clamped) value based on
value . |
static int |
saturate(int value,
int minimum,
int maximum)
Returns a saturated (or clamped) value based on
value . |
static float |
sin(float angle)
Returns the trigonometric sine of
angle . |
static float[] |
solveQuadraticSystem(float a,
float b,
float c)
Attempts to solve the quadratic system based on the values
a , b and c . |
static float |
sqrt(float value)
Returns the correctly rounded positive square root of
value . |
static float |
tan(float angle)
Returns the trigonometric tangent of
angle . |
static float |
toDegrees(float radians)
Returns an approximately equivalent angle measured in degrees from an angle measured in radians.
|
static float |
toFloat(double value)
Returns a
float representation of a double value. |
static float |
toRadians(float angleInDegrees)
Returns an approximately equivalent angle measured in radians from an angle measured in degrees.
|
static float |
wrapAround(float value,
float a,
float b)
Returns
value or its wrapped around representation. |
public static final float EPSILON
public static final float PI
float
representation of pi.public static final float PI_DIVIDED_BY_FOUR
float
representation of pi divided by 4.0F
.public static final float PI_DIVIDED_BY_TWO
float
representation of pi divided by 2.0F
.public static final float PI_MULTIPLIED_BY_TWO
float
representation of pi multiplied by 2.0F
.public static final float PI_RECIPROCAL
float
representation of the reciprocal of pi.public static boolean equals(float a, float b)
a
and b
for equality.
Returns true
if, and only if, a
and b
are equal, false
otherwise.
a
- a float
valueb
- a float
valuetrue
if, and only if, a
and b
are equal, false
otherwisepublic static float abs(float value)
value
.value
- a float
valuevalue
public static float acos(float value)
value
.value
- a float
valuevalue
public static float asin(float value)
value
.value
- a float
valuevalue
public static float atan(float value)
value
.value
- a float
valuevalue
public static float atan2(float y, float x)
y
- the ordinate coordinatex
- the abscissa coordinatepublic static float cos(float angle)
angle
.angle
- an angle, in radiansangle
public static float exp(float exponent)
e
raised to the power of exponent
.exponent
- the exponent to raise e
toe
raised to the power of exponent
public static float floor(float value)
float
value that is less than or equal to value
and is equal to a mathematical integer.value
- a valuefloat
value that is less than or equal to value
and is equal to a mathematical integerpublic static float max(float a, float b)
a
and b
.a
- a valueb
- a valuea
and b
public static float max(float a, float b, float c)
a
, b
and c
.a
- a valueb
- a valuec
- a valuea
, b
and c
public static float min(float a, float b)
a
and b
.a
- a valueb
- a valuea
and b
public static float min(float a, float b, float c)
a
, b
and c
.a
- a valueb
- a valuec
- a valuea
, b
and c
public static float modulo(float value)
value - floor(value)
.value
- a valuevalue - floor(value)
public static float nextFloat()
float
value between 0.0F
(inclusive) and 1.0F
(exclusive).float
value between 0.0F
(inclusive) and 1.0F
(exclusive)public static float pow(float base, float exponent)
base
raised to the power of exponent
.base
- the baseexponent
- the exponentbase
raised to the power of exponent
public static float saturate(float value)
value
.
Calling this method is equivalent to calling Math2.saturate(value, 0.0F, 1.0F)
.
value
- the value to saturate (or clamp)value
public static float saturate(float value, float minimum, float maximum)
value
.
If value
is less than minimum
, minimum
will be returned. If value
is greater than maximum
, maximum
will be returned. Otherwise value
will be returned.
value
- the value to saturate (or clamp)minimum
- the minimum valuemaximum
- the maximum valuevalue
public static float sin(float angle)
angle
.angle
- an angle, in radiansangle
public static float sqrt(float value)
value
.value
- a valuevalue
public static float tan(float angle)
angle
.angle
- an angle, in radiansangle
public static float toDegrees(float radians)
radians
- an angle, in radianspublic static float toFloat(double value)
float
representation of a double
value.value
- a double
valuefloat
representation of a double
valuepublic static float toRadians(float angleInDegrees)
angleInDegrees
- an angle, in degreespublic static float wrapAround(float value, float a, float b)
value
or its wrapped around representation.
If value
is greater than or equal to min(a, b)
and less than or equal to max(a, b)
, value
will be returned. Otherwise it will wrap around on either side until it is contained in the interval
[min(a, b), max(a, b)]
.
value
- the value to potentially wrap arounda
- one of the values in the interval to wrap aroundb
- one of the values in the interval to wrap aroundvalue
or its wrapped around representationpublic static float[] solveQuadraticSystem(float a, float b, float c)
a
, b
and c
.
Returns a float
array with a length of 2
containing the result.
If the quadratic system could not be solved, the result will contain the values Float.NaN
.
a
- a valueb
- a valuec
- a valuedouble
array with a length of 2
containing the resultpublic static int abs(int value)
value
.value
- an int
valuevalue
public static int max(int a, int b)
a
and b
.a
- a valueb
- a valuea
and b
public static int min(int a, int b)
a
and b
.a
- a valueb
- a valuea
and b
public static int saturate(int value)
value
.
Calling this method is equivalent to calling Math2.saturate(value, 0, 255)
.
value
- the value to saturate (or clamp)value
public static int saturate(int value, int minimum, int maximum)
value
.
If value
is less than minimum
, minimum
will be returned. If value
is greater than maximum
, maximum
will be returned. Otherwise value
will be returned.
value
- the value to saturate (or clamp)minimum
- the minimum valuemaximum
- the maximum valuevalue