public final class FastMath
extends java.lang.Object
FastMath provides 'fast' math approximations and float equivalents of Math
functions. These are all used as static values and functions.| Modifier and Type | Field and Description |
|---|---|
static float |
DEG_TO_RAD
A value to multiply a degree value by, to convert it to radians.
|
static float |
FLT_EPSILON
A "close to zero" double epsilon value for use
|
static float |
HALF_PI
The value PI/2 as a float.
|
static float |
PI
The value PI as a float.
|
static float |
QUARTER_PI
The value PI/4 as a float.
|
static float |
RAD_TO_DEG
A value to multiply a radian value by, to convert it to degrees.
|
static float |
TWO_PI
The value 2PI as a float.
|
| Modifier and Type | Method and Description |
|---|---|
static float |
abs(float fValue)
Returns Absolute value of a float.
|
static boolean |
approximateEquals(float a,
float b)
Determine if two floats are approximately equal.
|
static float |
atan(float fValue)
Returns the arc tangent of an angle given in radians.
|
static float |
atan2(float fY,
float fX)
A direct call to Math.atan2.
|
static float |
clamp(float input,
float min,
float max)
Take a float input and clamp it between min and max.
|
static float |
cos(float v)
Returns cosine of an angle.
|
static float |
pow(float fBase,
float fExponent)
Returns a number raised to an exponent power.
|
static float |
sin(float v)
Returns the sine of an angle.
|
static float |
sqrt(float fValue)
Returns the square root of a given value.
|
static float |
tan(float fValue)
Returns the tangent of the specified angle.
|
public static final float FLT_EPSILON
public static final float PI
public static final float TWO_PI
public static final float HALF_PI
public static final float QUARTER_PI
public static final float DEG_TO_RAD
public static final float RAD_TO_DEG
public static float atan(float fValue)
fValue - The angle, in radians.Math.atan(double)public static float atan2(float fY,
float fX)
fY - ordinatefX - abscissaMath.atan2(double, double)public static float cos(float v)
v - The angle to cosine.Math.cos(double)public static float sin(float v)
v - The angle to sine.Math.sin(double)public static float abs(float fValue)
fValue - The value to abs.Math.abs(float)public static float pow(float fBase,
float fExponent)
fBase - The base value (IE 2)fExponent - The exponent value (IE 3)Math.pow(double, double)public static float sqrt(float fValue)
fValue - The value to sqrt.Math.sqrt(double)public static float tan(float fValue)
fValue - The value to tangent, in radians.Math.tan(double)public static float clamp(float input,
float min,
float max)
input - the value to be clampedmin - the minimum output valuemax - the maximum output valuepublic static boolean approximateEquals(float a,
float b)
a - The first float to compareb - The second float to compare