public final class MathUtils extends Object
Modifier and Type | Method and Description |
---|---|
static float |
abs(float v) |
static float |
acos(float value) |
static int |
addOrThrow(int a,
int b)
Returns the sum of the two parameters, or throws an exception if the resulting sum would
cause an overflow or underflow.
|
static float |
asin(float value) |
static float |
atan(float value) |
static float |
atan2(float a,
float b) |
static float |
constrain(float amount,
float low,
float high) |
static int |
constrain(int amount,
int low,
int high) |
static long |
constrain(long amount,
long low,
long high) |
static float |
cross(float v1x,
float v1y,
float v2x,
float v2y) |
static float |
degrees(float radians) |
static float |
dist(float x1,
float y1,
float x2,
float y2) |
static float |
dist(float x1,
float y1,
float z1,
float x2,
float y2,
float z2) |
static float |
dot(float v1x,
float v1y,
float v2x,
float v2y) |
static float |
exp(float a) |
static float |
lerp(float start,
float stop,
float amount) |
static float |
lerpDeg(float start,
float end,
float amount)
Returns an interpolated angle in degrees between a set of start and end
angles.
|
static float |
log(float a) |
static float |
mag(float a,
float b) |
static float |
mag(float a,
float b,
float c) |
static float |
map(float minStart,
float minStop,
float maxStart,
float maxStop,
float value) |
static float |
max(float a,
float b) |
static float |
max(float a,
float b,
float c) |
static float |
max(int a,
int b) |
static float |
max(int a,
int b,
int c) |
static float |
min(float a,
float b) |
static float |
min(float a,
float b,
float c) |
static float |
min(int a,
int b) |
static float |
min(int a,
int b,
int c) |
static float |
norm(float start,
float stop,
float value) |
static float |
pow(float a,
float b) |
static float |
radians(float degrees) |
static float |
random(float howbig) |
static float |
random(float howsmall,
float howbig) |
static int |
random(int howbig) |
static int |
random(int howsmall,
int howbig) |
static void |
randomSeed(long seed) |
static float |
sq(float v) |
static float |
tan(float angle) |
public static float abs(float v)
public static int constrain(int amount, int low, int high)
public static long constrain(long amount, long low, long high)
public static float constrain(float amount, float low, float high)
public static float log(float a)
public static float exp(float a)
public static float pow(float a, float b)
public static float max(float a, float b)
public static float max(int a, int b)
public static float max(float a, float b, float c)
public static float max(int a, int b, int c)
public static float min(float a, float b)
public static float min(int a, int b)
public static float min(float a, float b, float c)
public static float min(int a, int b, int c)
public static float dist(float x1, float y1, float x2, float y2)
public static float dist(float x1, float y1, float z1, float x2, float y2, float z2)
public static float mag(float a, float b)
public static float mag(float a, float b, float c)
public static float sq(float v)
public static float dot(float v1x, float v1y, float v2x, float v2y)
public static float cross(float v1x, float v1y, float v2x, float v2y)
public static float radians(float degrees)
public static float degrees(float radians)
public static float acos(float value)
public static float asin(float value)
public static float atan(float value)
public static float atan2(float a, float b)
public static float tan(float angle)
public static float lerp(float start, float stop, float amount)
public static float lerpDeg(float start, float end, float amount)
Unlike lerp(float, float, float)
, the direction and distance of
travel is determined by the shortest angle between the start and end
angles. For example, if the starting angle is 0 and the ending angle is
350, then the interpolated angle will be in the range [0,-10] rather
than [0,350].
start
- the starting angle in degreesend
- the ending angle in degreesamount
- the position between start and end in the range [0,1]
where 0 is the starting angle and 1 is the ending anglepublic static float norm(float start, float stop, float value)
public static float map(float minStart, float minStop, float maxStart, float maxStop, float value)
public static int random(int howbig)
public static int random(int howsmall, int howbig)
public static float random(float howbig)
public static float random(float howsmall, float howbig)
public static void randomSeed(long seed)
public static int addOrThrow(int a, int b) throws IllegalArgumentException
IllegalArgumentException
- when overflow or underflow would occur.