public abstract static class Utils.MathUtils
extends java.lang.Object
Math| Modifier and Type | Field and Description |
|---|---|
static float |
HALF_PI
Half PI value as a float (90 degrees).
|
static float |
PI
PI value as a float (180 degrees).
|
static float |
QUARTER_PI
Quarter PI value as a float (45 degrees).
|
static float |
TWO_PI
Two PI value as a float (360 degrees).
|
| Constructor and Description |
|---|
MathUtils() |
| Modifier and Type | Method and Description |
|---|---|
static float |
abs(float value)
Gets the absolute value of a
float value. |
static int |
absInt(int value)
Gets the absolute value of an
int value. |
static float |
clamp(float min,
float max,
float value)
Clamps the value between min and max.
|
static float |
degreeToRadian(float degree)
Converts a degree value to radians.
|
static int |
getGCD(int... input)
Gets the greatest common divisor of several int values.
|
static int |
getGCD(int a,
int b)
Gets the greatest common divisor of two int values.
|
static boolean |
nextRandomBoolean()
Gets a random boolean value (true or false).
|
static float |
nextRandomFloat()
Gets a random float value between 0 and 1
|
static int |
nextRandomInt(int min,
int max)
Gets a random int value between min (inclusive) and
max (inclusive).
|
static float |
radianToDegree(float radian)
Converts a radian value to degree.
|
static float |
round(float value,
int digit)
Rounds a float value to a given decimal place.
|
static float |
smoothstep(float min,
float max,
float value)
Performs a smooth Hermite interpolation between 0 and 1.
|
static float |
sqr(float value)
Gets the value squared (value ^ 2).
|
static float |
sqrt(float value)
Gets the square root of a given value.
|
public static final float PI
public static final float HALF_PI
public static final float QUARTER_PI
public static final float TWO_PI
public static float abs(float value)
float value.value - the argument whose absolute value is to be determined.public static int absInt(int value)
int value.value - the argument whose absolute value is to be determined.public static float sqr(float value)
value - the value to square.public static float sqrt(float value)
value - the value you want to get the square root of.Math.sqrt(double)public static float degreeToRadian(float degree)
degree - the degree value.public static float radianToDegree(float radian)
radian - the radian value.public static float clamp(float min,
float max,
float value)
min - the min value.max - the max value.value - the value you want to clamp.public static float smoothstep(float min,
float max,
float value)
min - the lower edge value.max - the upper edge value.value - the source value for interpolation.public static int getGCD(int... input)
input - multiple int values you want to calculate the GCD of.public static int getGCD(int a,
int b)
a - first int value.b - second int value.public static float round(float value,
int digit)
value - the value you want to round.digit - the decimal places.public static float nextRandomFloat()
public static int nextRandomInt(int min,
int max)
min - the lower bound (inclusive)max - the upper bound (inclusive)public static boolean nextRandomBoolean()