Package com.jme3.math
Class FastMath
java.lang.Object
com.jme3.math.FastMath
FastMath
provides 'fast' math approximations and float equivalents of Math
functions. These are all used as static values and functions.-
Field Summary
Modifier and TypeFieldDescriptionstatic final float
A value to multiply a degree value by, to convert it to radians.static final float
A "close to zero" double epsilon value for usestatic final float
The value PI/2 as a float.static final float
The value PI as a float.static final float
The value PI/4 as a float.static final float
A value to multiply a radian value by, to convert it to degrees.static final float
The value 2PI as a float. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Field Details
-
FLT_EPSILON
public static final float FLT_EPSILONA "close to zero" double epsilon value for use- See Also:
-
PI
public static final float PIThe value PI as a float. (180 degrees)- See Also:
-
TWO_PI
public static final float TWO_PIThe value 2PI as a float. (360 degrees)- See Also:
-
HALF_PI
public static final float HALF_PIThe value PI/2 as a float. (90 degrees)- See Also:
-
QUARTER_PI
public static final float QUARTER_PIThe value PI/4 as a float. (45 degrees)- See Also:
-
DEG_TO_RAD
public static final float DEG_TO_RADA value to multiply a degree value by, to convert it to radians.- See Also:
-
RAD_TO_DEG
public static final float RAD_TO_DEGA value to multiply a radian value by, to convert it to degrees.- See Also:
-
-
Method Details
-
atan
public static float atan(float fValue) Returns the arc tangent of an angle given in radians.- Parameters:
fValue
- The angle, in radians.- Returns:
- fValue's atan
- See Also:
-
atan2
public static float atan2(float fY, float fX) A direct call to Math.atan2.- Parameters:
fY
- ordinatefX
- abscissa- Returns:
- Math.atan2(fY,fX)
- See Also:
-
cos
public static float cos(float v) Returns cosine of an angle. Direct call to java.lang.Math- Parameters:
v
- The angle to cosine.- Returns:
- the cosine of the angle.
- See Also:
-
sin
public static float sin(float v) Returns the sine of an angle. Direct call to java.lang.Math- Parameters:
v
- The angle to sine.- Returns:
- the sine of the angle.
- See Also:
-
abs
public static float abs(float fValue) Returns Absolute value of a float.- Parameters:
fValue
- The value to abs.- Returns:
- The abs of the value.
- See Also:
-
pow
public static float pow(float fBase, float fExponent) Returns a number raised to an exponent power. fBase^fExponent- Parameters:
fBase
- The base value (IE 2)fExponent
- The exponent value (IE 3)- Returns:
- base raised to exponent (IE 8)
- See Also:
-
sqrt
public static float sqrt(float fValue) Returns the square root of a given value.- Parameters:
fValue
- The value to sqrt.- Returns:
- The square root of the given value.
- See Also:
-
tan
public static float tan(float fValue) Returns the tangent of the specified angle.- Parameters:
fValue
- The value to tangent, in radians.- Returns:
- The tangent of fValue.
- See Also:
-
clamp
public static float clamp(float input, float min, float max) Take a float input and clamp it between min and max.- Parameters:
input
- the value to be clampedmin
- the minimum output valuemax
- the maximum output value- Returns:
- clamped input
-
approximateEquals
public static boolean approximateEquals(float a, float b) Determine if two floats are approximately equal. This takes into account the magnitude of the floats, since large numbers will have larger differences be close to each other. Should return true for a=100000, b=100001, but false for a=10000, b=10001.- Parameters:
a
- The first float to compareb
- The second float to compare- Returns:
- True if a and b are approximately equal, false otherwise.
-