com.jme3.math
Class FastMath

java.lang.Object
  extended by com.jme3.math.FastMath

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.


Field Summary
static double DBL_EPSILON
          A "close to zero" double epsilon value for use
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" float epsilon value for use
static float HALF_PI
          The value PI/2 as a float.
static float INV_PI
          The value 1/PI as a float.
static float INV_TWO_PI
          The value 1/(2PI) as a float.
static float ONE_THIRD
           
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 java.util.Random rand
          A precreated random object for random numbers.
static float TWO_PI
          The value 2PI as a float.
static float ZERO_TOLERANCE
          A "close to zero" float epsilon value for use
 
Method Summary
static float abs(float fValue)
          Returns Absolute value of a float.
static float acos(float fValue)
          Returns the arc cosine of an angle given in radians.
Special cases: If fValue is smaller than -1, then the result is PI.
static float asin(float fValue)
          Returns the arc sine of an angle given in radians.
Special cases: If fValue is smaller than -1, then the result is -HALF_PI.
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 Vector3f cartesianToSpherical(Vector3f cartCoords, Vector3f store)
          Converts a point from Cartesian coordinates (using positive Y as up) to Spherical and stores the results in the store var.
static Vector3f cartesianZToSpherical(Vector3f cartCoords, Vector3f store)
          Converts a point from Cartesian coordinates (using positive Z as up) to Spherical and stores the results in the store var.
static float ceil(float fValue)
          Rounds a fValue up.
static float clamp(float input, float min, float max)
          Take a float input and clamp it between min and max.
static Vector3f computeNormal(Vector3f v1, Vector3f v2, Vector3f v3)
          A method that computes normal for a triangle defined by three vertices.
static short convertFloatToHalf(float flt)
           
static float convertHalfToFloat(short half)
          Converts a single precision (32 bit) floating point value into half precision (16 bit).
static float copysign(float x, float y)
           
static float cos(float v)
           
static float cos2(float fValue)
          Returns cos of a value.
static int counterClockwise(Vector2f p0, Vector2f p1, Vector2f p2)
          Given 3 points in a 2d plane, this function computes if the points going from A-B-C are moving counter clock wise.
static float determinant(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33)
          Returns the determinant of a 4x4 matrix.
static float exp(float fValue)
          Returns E^fValue
static float extrapolateLinear(float scale, float startValue, float endValue)
          Linear extrapolation from startValue to endValue by the given scale.
static Vector3f extrapolateLinear(float scale, Vector3f startValue, Vector3f endValue)
          Linear extrapolation from startValue to endValue by the given scale.
static Vector3f extrapolateLinear(float scale, Vector3f startValue, Vector3f endValue, Vector3f store)
          Linear extrapolation from startValue to endValue by the given scale.
static float fastInvSqrt(float x)
           
static float floor(float fValue)
          Returns a number rounded down.
static float getBezierP1toP2Length(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3)
          Compute the lenght on a bezier spline between control point 1 and 2
static float getCatmullRomP1toP2Length(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3, float startRange, float endRange, float curveTension)
          Compute the lenght on a catmull rom spline between control point 1 and 2
static float interpolateBezier(float u, float p0, float p1, float p2, float p3)
          Interpolate a spline between at least 4 control points following the Bezier equation.
static Vector3f interpolateBezier(float u, Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3)
          Interpolate a spline between at least 4 control points following the Bezier equation.
static Vector3f interpolateBezier(float u, Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3, Vector3f store)
          Interpolate a spline between at least 4 control points following the Bezier equation.
static float interpolateCatmullRom(float u, float T, float p0, float p1, float p2, float p3)
          Interpolate a spline between at least 4 control points following the Catmull-Rom equation.
static Vector3f interpolateCatmullRom(float u, float T, Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3)
          Interpolate a spline between at least 4 control points following the Catmull-Rom equation.
static Vector3f interpolateCatmullRom(float u, float T, Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3, Vector3f store)
          Interpolate a spline between at least 4 control points following the Catmull-Rom equation.
static float interpolateLinear(float scale, float startValue, float endValue)
          Linear interpolation from startValue to endValue by the given percent.
static Vector3f interpolateLinear(float scale, Vector3f startValue, Vector3f endValue)
          Linear interpolation from startValue to endValue by the given percent.
static Vector3f interpolateLinear(float scale, Vector3f startValue, Vector3f endValue, Vector3f store)
          Linear interpolation from startValue to endValue by the given percent.
static float invSqrt(float fValue)
          Returns 1/sqrt(fValue)
static boolean isPowerOfTwo(int number)
          Returns true if the number is a power of 2 (2,4,8,16...) A good implementation found on the Java boards.
static float log(float fValue)
          Returns the log base E of a value.
static float log(float value, float base)
          Returns the logarithm of value with given base, calculated as log(value)/log(base), so that pow(base, return)==value (contributed by vear)
static int nearestPowerOfTwo(int number)
           
static float nextRandomFloat()
          Returns a random float between 0 and 1.
static int nextRandomInt()
           
static int nextRandomInt(int min, int max)
          Returns a random integer between min and max.
static float normalize(float val, float min, float max)
          Takes an value and expresses it in terms of min to max.
static int pointInsideTriangle(Vector2f t0, Vector2f t1, Vector2f t2, Vector2f p)
          Test if a point is inside a triangle.
static float pow(float fBase, float fExponent)
          Returns a number raised to an exponent power.
static float reduceSinAngle(float radians)
          Fast Trig functions for x86.
static float saturate(float input)
          Clamps the given float to be between 0 and 1.
static float sign(float fValue)
          Returns 1 if the number is positive, -1 if the number is negative, and 0 otherwise
static int sign(int iValue)
          Returns 1 if the number is positive, -1 if the number is negative, and 0 otherwise
static float sin(float v)
           
static float sin2(float fValue)
          Returns sine of a value.
static Vector3f sphericalToCartesian(Vector3f sphereCoords, Vector3f store)
          Converts a point from Spherical coordinates to Cartesian (using positive Y as up) and stores the results in the store var.
static Vector3f sphericalToCartesianZ(Vector3f sphereCoords, Vector3f store)
          Converts a point from Spherical coordinates to Cartesian (using positive Z as up) and stores the results in the store var.
static float sqr(float fValue)
          Returns the value squared.
static float sqrt(float fValue)
          Returns the square root of a given value.
static float tan(float fValue)
          Returns the tangent of a value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBL_EPSILON

public static final double DBL_EPSILON
A "close to zero" double epsilon value for use

See Also:
Constant Field Values

FLT_EPSILON

public static final float FLT_EPSILON
A "close to zero" float epsilon value for use

See Also:
Constant Field Values

ZERO_TOLERANCE

public static final float ZERO_TOLERANCE
A "close to zero" float epsilon value for use

See Also:
Constant Field Values

ONE_THIRD

public static final float ONE_THIRD
See Also:
Constant Field Values

PI

public static final float PI
The value PI as a float. (180 degrees)

See Also:
Constant Field Values

TWO_PI

public static final float TWO_PI
The value 2PI as a float. (360 degrees)

See Also:
Constant Field Values

HALF_PI

public static final float HALF_PI
The value PI/2 as a float. (90 degrees)

See Also:
Constant Field Values

QUARTER_PI

public static final float QUARTER_PI
The value PI/4 as a float. (45 degrees)

See Also:
Constant Field Values

INV_PI

public static final float INV_PI
The value 1/PI as a float.

See Also:
Constant Field Values

INV_TWO_PI

public static final float INV_TWO_PI
The value 1/(2PI) as a float.

See Also:
Constant Field Values

DEG_TO_RAD

public static final float DEG_TO_RAD
A value to multiply a degree value by, to convert it to radians.

See Also:
Constant Field Values

RAD_TO_DEG

public static final float RAD_TO_DEG
A value to multiply a radian value by, to convert it to degrees.

See Also:
Constant Field Values

rand

public static final java.util.Random rand
A precreated random object for random numbers.

Method Detail

isPowerOfTwo

public static boolean isPowerOfTwo(int number)
Returns true if the number is a power of 2 (2,4,8,16...) A good implementation found on the Java boards. note: a number is a power of two if and only if it is the smallest number with that number of significant bits. Therefore, if you subtract 1, you know that the new number will have fewer bits, so ANDing the original number with anything less than it will give 0.

Parameters:
number - The number to test.
Returns:
True if it is a power of two.

nearestPowerOfTwo

public static int nearestPowerOfTwo(int number)

interpolateLinear

public static float interpolateLinear(float scale,
                                      float startValue,
                                      float endValue)
Linear interpolation from startValue to endValue by the given percent. Basically: ((1 - percent) * startValue) + (percent * endValue)

Parameters:
scale - scale value to use. if 1, use endValue, if 0, use startValue.
startValue - Begining value. 0% of f
endValue - ending value. 100% of f
Returns:
The interpolated value between startValue and endValue.

interpolateLinear

public static Vector3f interpolateLinear(float scale,
                                         Vector3f startValue,
                                         Vector3f endValue,
                                         Vector3f store)
Linear interpolation from startValue to endValue by the given percent. Basically: ((1 - percent) * startValue) + (percent * endValue)

Parameters:
scale - scale value to use. if 1, use endValue, if 0, use startValue.
startValue - Begining value. 0% of f
endValue - ending value. 100% of f
store - a vector3f to store the result
Returns:
The interpolated value between startValue and endValue.

interpolateLinear

public static Vector3f interpolateLinear(float scale,
                                         Vector3f startValue,
                                         Vector3f endValue)
Linear interpolation from startValue to endValue by the given percent. Basically: ((1 - percent) * startValue) + (percent * endValue)

Parameters:
scale - scale value to use. if 1, use endValue, if 0, use startValue.
startValue - Begining value. 0% of f
endValue - ending value. 100% of f
Returns:
The interpolated value between startValue and endValue.

extrapolateLinear

public static float extrapolateLinear(float scale,
                                      float startValue,
                                      float endValue)
Linear extrapolation from startValue to endValue by the given scale. if scale is between 0 and 1 this method returns the same result as interpolateLinear if the scale is over 1 the value is linearly extrapolated. Note that the end value is the value for a scale of 1.

Parameters:
scale - the scale for extrapolation
startValue - the starting value (scale = 0)
endValue - the end value (scale = 1)
Returns:
an extrapolation for the given parameters

extrapolateLinear

public static Vector3f extrapolateLinear(float scale,
                                         Vector3f startValue,
                                         Vector3f endValue,
                                         Vector3f store)
Linear extrapolation from startValue to endValue by the given scale. if scale is between 0 and 1 this method returns the same result as interpolateLinear if the scale is over 1 the value is linearly extrapolated. Note that the end value is the value for a scale of 1.

Parameters:
scale - the scale for extrapolation
startValue - the starting value (scale = 0)
endValue - the end value (scale = 1)
store - an initialized vector to store the return value
Returns:
an extrapolation for the given parameters

extrapolateLinear

public static Vector3f extrapolateLinear(float scale,
                                         Vector3f startValue,
                                         Vector3f endValue)
Linear extrapolation from startValue to endValue by the given scale. if scale is between 0 and 1 this method returns the same result as interpolateLinear if the scale is over 1 the value is linearly extrapolated. Note that the end value is the value for a scale of 1.

Parameters:
scale - the scale for extrapolation
startValue - the starting value (scale = 0)
endValue - the end value (scale = 1)
Returns:
an extrapolation for the given parameters

interpolateCatmullRom

public static float interpolateCatmullRom(float u,
                                          float T,
                                          float p0,
                                          float p1,
                                          float p2,
                                          float p3)
Interpolate a spline between at least 4 control points following the Catmull-Rom equation. here is the interpolation matrix m = [ 0.0 1.0 0.0 0.0 ] [-T 0.0 T 0.0 ] [ 2T T-3 3-2T -T ] [-T 2-T T-2 T ] where T is the curve tension the result is a value between p1 and p2, t=0 for p1, t=1 for p2

Parameters:
u - value from 0 to 1
T - The tension of the curve
p0 - control point 0
p1 - control point 1
p2 - control point 2
p3 - control point 3
Returns:
catmull-Rom interpolation

interpolateCatmullRom

public static Vector3f interpolateCatmullRom(float u,
                                             float T,
                                             Vector3f p0,
                                             Vector3f p1,
                                             Vector3f p2,
                                             Vector3f p3,
                                             Vector3f store)
Interpolate a spline between at least 4 control points following the Catmull-Rom equation. here is the interpolation matrix m = [ 0.0 1.0 0.0 0.0 ] [-T 0.0 T 0.0 ] [ 2T T-3 3-2T -T ] [-T 2-T T-2 T ] where T is the tension of the curve the result is a value between p1 and p2, t=0 for p1, t=1 for p2

Parameters:
u - value from 0 to 1
T - The tension of the curve
p0 - control point 0
p1 - control point 1
p2 - control point 2
p3 - control point 3
store - a Vector3f to store the result
Returns:
catmull-Rom interpolation

interpolateCatmullRom

public static Vector3f interpolateCatmullRom(float u,
                                             float T,
                                             Vector3f p0,
                                             Vector3f p1,
                                             Vector3f p2,
                                             Vector3f p3)
Interpolate a spline between at least 4 control points following the Catmull-Rom equation. here is the interpolation matrix m = [ 0.0 1.0 0.0 0.0 ] [-T 0.0 T 0.0 ] [ 2T T-3 3-2T -T ] [-T 2-T T-2 T ] where T is the tension of the curve the result is a value between p1 and p2, t=0 for p1, t=1 for p2

Parameters:
u - value from 0 to 1
T - The tension of the curve
p0 - control point 0
p1 - control point 1
p2 - control point 2
p3 - control point 3
Returns:
catmull-Rom interpolation

interpolateBezier

public static float interpolateBezier(float u,
                                      float p0,
                                      float p1,
                                      float p2,
                                      float p3)
Interpolate a spline between at least 4 control points following the Bezier equation. here is the interpolation matrix m = [ -1.0 3.0 -3.0 1.0 ] [ 3.0 -6.0 3.0 0.0 ] [ -3.0 3.0 0.0 0.0 ] [ 1.0 0.0 0.0 0.0 ] where T is the curve tension the result is a value between p1 and p3, t=0 for p1, t=1 for p3

Parameters:
u - value from 0 to 1
p0 - control point 0
p1 - control point 1
p2 - control point 2
p3 - control point 3
Returns:
Bezier interpolation

interpolateBezier

public static Vector3f interpolateBezier(float u,
                                         Vector3f p0,
                                         Vector3f p1,
                                         Vector3f p2,
                                         Vector3f p3,
                                         Vector3f store)
Interpolate a spline between at least 4 control points following the Bezier equation. here is the interpolation matrix m = [ -1.0 3.0 -3.0 1.0 ] [ 3.0 -6.0 3.0 0.0 ] [ -3.0 3.0 0.0 0.0 ] [ 1.0 0.0 0.0 0.0 ] where T is the tension of the curve the result is a value between p1 and p3, t=0 for p1, t=1 for p3

Parameters:
u - value from 0 to 1
p0 - control point 0
p1 - control point 1
p2 - control point 2
p3 - control point 3
store - a Vector3f to store the result
Returns:
Bezier interpolation

interpolateBezier

public static Vector3f interpolateBezier(float u,
                                         Vector3f p0,
                                         Vector3f p1,
                                         Vector3f p2,
                                         Vector3f p3)
Interpolate a spline between at least 4 control points following the Bezier equation. here is the interpolation matrix m = [ -1.0 3.0 -3.0 1.0 ] [ 3.0 -6.0 3.0 0.0 ] [ -3.0 3.0 0.0 0.0 ] [ 1.0 0.0 0.0 0.0 ] where T is the tension of the curve the result is a value between p1 and p3, t=0 for p1, t=1 for p3

Parameters:
u - value from 0 to 1
p0 - control point 0
p1 - control point 1
p2 - control point 2
p3 - control point 3
Returns:
Bezier interpolation

getCatmullRomP1toP2Length

public static float getCatmullRomP1toP2Length(Vector3f p0,
                                              Vector3f p1,
                                              Vector3f p2,
                                              Vector3f p3,
                                              float startRange,
                                              float endRange,
                                              float curveTension)
Compute the lenght on a catmull rom spline between control point 1 and 2

Parameters:
p0 - control point 0
p1 - control point 1
p2 - control point 2
p3 - control point 3
startRange - the starting range on the segment (use 0)
endRange - the end range on the segment (use 1)
curveTension - the curve tension
Returns:
the length of the segment

getBezierP1toP2Length

public static float getBezierP1toP2Length(Vector3f p0,
                                          Vector3f p1,
                                          Vector3f p2,
                                          Vector3f p3)
Compute the lenght on a bezier spline between control point 1 and 2

Parameters:
p0 - control point 0
p1 - control point 1
p2 - control point 2
p3 - control point 3
Returns:
the length of the segment

acos

public static float acos(float fValue)
Returns the arc cosine of an angle given in radians.
Special cases:

Parameters:
fValue - The angle, in radians.
Returns:
fValue's acos
See Also:
Math.acos(double)

asin

public static float asin(float fValue)
Returns the arc sine of an angle given in radians.
Special cases:

Parameters:
fValue - The angle, in radians.
Returns:
fValue's asin
See Also:
Math.asin(double)

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:
Math.atan(double)

atan2

public static float atan2(float fY,
                          float fX)
A direct call to Math.atan2.

Parameters:
fY -
fX -
Returns:
Math.atan2(fY,fX)
See Also:
Math.atan2(double, double)

ceil

public static float ceil(float fValue)
Rounds a fValue up. A call to Math.ceil

Parameters:
fValue - The value.
Returns:
The fValue rounded up
See Also:
Math.ceil(double)

reduceSinAngle

public static float reduceSinAngle(float radians)
Fast Trig functions for x86. This forces the trig functiosn to stay within the safe area on the x86 processor (-45 degrees to +45 degrees) The results may be very slightly off from what the Math and StrictMath trig functions give due to rounding in the angle reduction but it will be very very close. note: code from wiki posting on java.net by jeffpk


sin2

public static float sin2(float fValue)
Returns sine of a value. note: code from wiki posting on java.net by jeffpk

Parameters:
fValue - The value to sine, in radians.
Returns:
The sine of fValue.
See Also:
Math.sin(double)

cos2

public static float cos2(float fValue)
Returns cos of a value.

Parameters:
fValue - The value to cosine, in radians.
Returns:
The cosine of fValue.
See Also:
Math.cos(double)

cos

public static float cos(float v)

sin

public static float sin(float v)

exp

public static float exp(float fValue)
Returns E^fValue

Parameters:
fValue - Value to raise to a power.
Returns:
The value E^fValue
See Also:
Math.exp(double)

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:
Math.abs(float)

floor

public static float floor(float fValue)
Returns a number rounded down.

Parameters:
fValue - The value to round
Returns:
The given number rounded down
See Also:
Math.floor(double)

invSqrt

public static float invSqrt(float fValue)
Returns 1/sqrt(fValue)

Parameters:
fValue - The value to process.
Returns:
1/sqrt(fValue)
See Also:
Math.sqrt(double)

fastInvSqrt

public static float fastInvSqrt(float x)

log

public static float log(float fValue)
Returns the log base E of a value.

Parameters:
fValue - The value to log.
Returns:
The log of fValue base E
See Also:
Math.log(double)

log

public static float log(float value,
                        float base)
Returns the logarithm of value with given base, calculated as log(value)/log(base), so that pow(base, return)==value (contributed by vear)

Parameters:
value - The value to log.
base - Base of logarithm.
Returns:
The logarithm of value with given base

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:
Math.pow(double, double)

sqr

public static float sqr(float fValue)
Returns the value squared. fValue ^ 2

Parameters:
fValue - The vaule to square.
Returns:
The square of the given value.

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:
Math.sqrt(double)

tan

public static float tan(float fValue)
Returns the tangent of a value. If USE_FAST_TRIG is enabled, an approximate value is returned. Otherwise, a direct value is used.

Parameters:
fValue - The value to tangent, in radians.
Returns:
The tangent of fValue.
See Also:
Math.tan(double)

sign

public static int sign(int iValue)
Returns 1 if the number is positive, -1 if the number is negative, and 0 otherwise

Parameters:
iValue - The integer to examine.
Returns:
The integer's sign.

sign

public static float sign(float fValue)
Returns 1 if the number is positive, -1 if the number is negative, and 0 otherwise

Parameters:
fValue - The float to examine.
Returns:
The float's sign.

counterClockwise

public static int counterClockwise(Vector2f p0,
                                   Vector2f p1,
                                   Vector2f p2)
Given 3 points in a 2d plane, this function computes if the points going from A-B-C are moving counter clock wise.

Parameters:
p0 - Point 0.
p1 - Point 1.
p2 - Point 2.
Returns:
1 If they are CCW, -1 if they are not CCW, 0 if p2 is between p0 and p1.

pointInsideTriangle

public static int pointInsideTriangle(Vector2f t0,
                                      Vector2f t1,
                                      Vector2f t2,
                                      Vector2f p)
Test if a point is inside a triangle. 1 if the point is on the ccw side, -1 if the point is on the cw side, and 0 if it is on neither.

Parameters:
t0 - First point of the triangle.
t1 - Second point of the triangle.
t2 - Third point of the triangle.
p - The point to test.
Returns:
Value 1 or -1 if inside triangle, 0 otherwise.

computeNormal

public static Vector3f computeNormal(Vector3f v1,
                                     Vector3f v2,
                                     Vector3f v3)
A method that computes normal for a triangle defined by three vertices.

Parameters:
v1 - first vertex
v2 - second vertex
v3 - third vertex
Returns:
a normal for the face

determinant

public static float determinant(double m00,
                                double m01,
                                double m02,
                                double m03,
                                double m10,
                                double m11,
                                double m12,
                                double m13,
                                double m20,
                                double m21,
                                double m22,
                                double m23,
                                double m30,
                                double m31,
                                double m32,
                                double m33)
Returns the determinant of a 4x4 matrix.


nextRandomFloat

public static float nextRandomFloat()
Returns a random float between 0 and 1.

Returns:
A random float between 0.0f (inclusive) to 1.0f (exclusive).

nextRandomInt

public static int nextRandomInt(int min,
                                int max)
Returns a random integer between min and max.

Returns:
A random int between min (inclusive) to max (inclusive).

nextRandomInt

public static int nextRandomInt()

sphericalToCartesian

public static Vector3f sphericalToCartesian(Vector3f sphereCoords,
                                            Vector3f store)
Converts a point from Spherical coordinates to Cartesian (using positive Y as up) and stores the results in the store var.


cartesianToSpherical

public static Vector3f cartesianToSpherical(Vector3f cartCoords,
                                            Vector3f store)
Converts a point from Cartesian coordinates (using positive Y as up) to Spherical and stores the results in the store var. (Radius, Azimuth, Polar)


sphericalToCartesianZ

public static Vector3f sphericalToCartesianZ(Vector3f sphereCoords,
                                             Vector3f store)
Converts a point from Spherical coordinates to Cartesian (using positive Z as up) and stores the results in the store var.


cartesianZToSpherical

public static Vector3f cartesianZToSpherical(Vector3f cartCoords,
                                             Vector3f store)
Converts a point from Cartesian coordinates (using positive Z as up) to Spherical and stores the results in the store var. (Radius, Azimuth, Polar)


normalize

public static float normalize(float val,
                              float min,
                              float max)
Takes an value and expresses it in terms of min to max.

Parameters:
val - - the angle to normalize (in radians)
Returns:
the normalized angle (also in radians)

copysign

public static float copysign(float x,
                             float y)
Parameters:
x - the value whose sign is to be adjusted.
y - the value whose sign is to be used.
Returns:
x with its sign changed to match the sign of y.

clamp

public static float clamp(float input,
                          float min,
                          float max)
Take a float input and clamp it between min and max.

Parameters:
input -
min -
max -
Returns:
clamped input

saturate

public static float saturate(float input)
Clamps the given float to be between 0 and 1.

Parameters:
input -
Returns:
input clamped between 0 and 1.

convertHalfToFloat

public static float convertHalfToFloat(short half)
Converts a single precision (32 bit) floating point value into half precision (16 bit).

Source: http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf
broken link

Parameters:
half - The half floating point value as a short.
Returns:
floating point value of the half.

convertFloatToHalf

public static short convertFloatToHalf(float flt)