|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.badlogic.gdx.math.MathUtils
public class MathUtils
Utility and fast math functions.
Thanks to Riven on JavaGaming.org for the basis of sin/cos/atan2/floor/ceil.
Field Summary | |
---|---|
static float |
degRad
|
static float |
degreesToRadians
|
static float |
nanoToSec
|
static float |
PI
|
static float |
PI2
|
static float |
radDeg
|
static float |
radiansToDegrees
|
static Random |
random
|
Constructor Summary | |
---|---|
MathUtils()
|
Method Summary | |
---|---|
static float |
atan2(float y,
float x)
Returns atan2 in radians from a lookup table. |
static int |
ceil(float x)
Returns the smallest integer greater than or equal to the specified float. |
static int |
ceilPositive(float x)
Returns the smallest integer greater than or equal to the specified float. |
static float |
clamp(float value,
float min,
float max)
|
static int |
clamp(int value,
int min,
int max)
|
static short |
clamp(short value,
short min,
short max)
|
static float |
cos(float radians)
Returns the cosine in radians from a lookup table. |
static float |
cosDeg(float degrees)
Returns the cosine in radians from a lookup table. |
static int |
floor(float x)
Returns the largest integer less than or equal to the specified float. |
static int |
floorPositive(float x)
Returns the largest integer less than or equal to the specified float. |
static boolean |
isPowerOfTwo(int value)
|
static int |
nextPowerOfTwo(int value)
Returns the next power of two. |
static float |
random()
Returns random number between 0.0 (inclusive) and 1.0 (exclusive). |
static float |
random(float range)
Returns a random number between 0 (inclusive) and the specified value (exclusive). |
static float |
random(float start,
float end)
Returns a random number between start (inclusive) and end (exclusive). |
static int |
random(int range)
Returns a random number between 0 (inclusive) and the specified value (inclusive). |
static int |
random(int start,
int end)
Returns a random number between start (inclusive) and end (inclusive). |
static boolean |
randomBoolean()
Returns a random boolean value. |
static boolean |
randomBoolean(float chance)
Returns true if a random value between 0 and 1 is less than the specified value. |
static int |
round(float x)
Returns the closest integer to the specified float. |
static int |
roundPositive(float x)
Returns the closest integer to the specified float. |
static float |
sin(float radians)
Returns the sine in radians from a lookup table. |
static float |
sinDeg(float degrees)
Returns the sine in radians from a lookup table. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final float nanoToSec
public static final float PI
public static final float PI2
public static final float radiansToDegrees
public static final float radDeg
public static final float degreesToRadians
public static final float degRad
public static Random random
Constructor Detail |
---|
public MathUtils()
Method Detail |
---|
public static final float sin(float radians)
public static final float cos(float radians)
public static final float sinDeg(float degrees)
public static final float cosDeg(float degrees)
public static final float atan2(float y, float x)
public static final int random(int range)
public static final int random(int start, int end)
public static final boolean randomBoolean()
public static final boolean randomBoolean(float chance)
public static final float random()
public static final float random(float range)
public static final float random(float start, float end)
public static int nextPowerOfTwo(int value)
public static boolean isPowerOfTwo(int value)
public static int clamp(int value, int min, int max)
public static short clamp(short value, short min, short max)
public static float clamp(float value, float min, float max)
public static int floor(float x)
public static int floorPositive(float x)
public static int ceil(float x)
public static int ceilPositive(float x)
public static int round(float x)
public static int roundPositive(float x)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |