public final class MyMath
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.util.logging.Logger |
logger
message logger for this class
|
static float |
phi
golden ratio = 1.618...
|
static float |
root2
square root of 2
|
static float |
rootHalf
square root of 1/2
|
| Modifier and Type | Method and Description |
|---|---|
static double |
area(Triangle triangle)
Return the (one-sided) area of the specified triangle.
|
static double |
circle(double abscissa)
Return the circle function
sqrt(1 - x^2) for a double-precision
value. |
static float |
circle(float abscissa)
Return the circle function
sqrt(1 - x^2) for a single-precision
value. |
static double |
clamp(double dValue,
double min,
double max)
Clamp a double-precision value between 2 limits.
|
static int |
clamp(int iValue,
int min,
int max)
Clamp an integer value between 2 limits.
|
static Transform |
combine(Transform child,
Transform parent,
Transform storeResult)
Combine the specified transforms.
|
static float |
cube(float fValue)
Cube the specified single-precision value.
|
static Matrix3f |
fromAngles(float xAngle,
float yAngle,
float zAngle,
Matrix3f storeResult)
Sets a rotation matrix from the specified Tait-Bryan angles, applying the
rotations in x-z-y extrinsic order or y-z'-x" intrinsic order.
|
static float |
hypotenuse(float... fValues)
Return the root sum of squares of some single-precision values.
|
static double |
hypotenuseDouble(double... dValues)
Return the root sum of squares of some double-precision values.
|
static boolean |
isBetween(float a,
float b,
float c)
Test whether b is between a and c.
|
static boolean |
isFinite(float value)
Test whether the specified floating-point value is finite.
|
static boolean |
isFiniteDouble(double value)
Test whether the specified floating-point value is finite.
|
static boolean |
isIdentity(Transform transform)
Test the specified transform for exact identity.
|
static boolean |
isOdd(int iValue)
Test whether an integer value is odd.
|
static float |
lerp(float t,
float y0,
float y1)
Interpolate linearly between (or extrapolate linearly from) 2
single-precision values.
|
static int |
log2(int iValue)
Calculate the floor of the base-2 logarithm of the input value.
|
static float |
max(float... fValues)
Find the maximum of some single-precision values.
|
static int |
maxInt(int... iValues)
Find the maximum of some int values.
|
static float |
mid(float a,
float b,
float c)
Find the median of 3 single-precision values.
|
static float |
min(float... fValues)
Find the minimum of some single-precision values.
|
static float |
modulo(float fValue,
float modulus)
Return the least non-negative value congruent with the input value with
respect to the specified modulus.
|
static int |
modulo(int iValue,
int modulus)
Return the least non-negative value congruent with the input value with
respect to the specified modulus.
|
static float |
standardize(float fValue)
Standardize a single-precision value in preparation for hashing.
|
static float |
standardizeAngle(float angle)
Standardize a rotation angle to the range [-Pi, Pi).
|
static double |
sumOfSquares(float... fValues)
Return the sum of squares of some single-precision values.
|
static float |
toDegrees(float radians)
Convert an angle from radians to degrees.
|
static float |
toRadians(float degrees)
Convert an angle from degrees to radians.
|
static Vector3f |
transform(Transform transform,
Vector3f input,
Vector3f storeResult)
Apply the specified transform to a Vector3f.
|
static Triangle |
transformInverse(Transform transform,
Triangle input,
Triangle storeResult)
Apply the inverse of the specified transform to each vertex of a
Triangle.
|
static Vector3f |
transformInverse(Transform transform,
Vector3f input,
Vector3f storeResult)
Apply the inverse of the specified transform to a Vector3f.
|
public static final float phi
public static final float root2
public static final float rootHalf
public static final java.util.logging.Logger logger
public static double area(Triangle triangle)
triangle - (not null, unaffected)public static double circle(double abscissa)
sqrt(1 - x^2) for a double-precision
value.abscissa - input (≤1, ≥-1)public static float circle(float abscissa)
sqrt(1 - x^2) for a single-precision
value. Double-precision arithmetic is used to reduce the risk of
overflow.abscissa - input (≤1, ≥-1)public static double clamp(double dValue,
double min,
double max)
dValue - input value to be clampedmin - lower limit of the clampmax - upper limit of the clampFastMath.clamp(float,float,float)public static int clamp(int iValue,
int min,
int max)
iValue - input value to be clampedmin - the lower limitmax - the upper limitpublic static Transform combine(Transform child, Transform parent, Transform storeResult)
It is safe for any or all of child, parent, and
storeResult to be the same object.
This method works on transforms containing non-normalized quaternions.
child - the transform applied first (not null, unaffected unless
it's storeResult)parent - the transform applied last (not null, unaffected unless
it's storeResult)storeResult - (modified if not null)child followed by
parent (either storeResult or a new instance)public static float cube(float fValue)
fValue - input value to be cubedpublic static Matrix3f fromAngles(float xAngle, float yAngle, float zAngle, Matrix3f storeResult)
xAngle - the X angle (in radians)yAngle - the Y angle (in radians)zAngle - the Z angle (in radians)storeResult - storage for the result (modified if not null)storeResult or a new instance)public static float hypotenuse(float... fValues)
fValues - the input valuespublic static double hypotenuseDouble(double... dValues)
dValues - the input valuespublic static boolean isBetween(float a,
float b,
float c)
a - the first input valueb - the 2nd input valuec - the 3rd input valuepublic static boolean isFinite(float value)
Float.isFinite(float).value - the value to testpublic static boolean isFiniteDouble(double value)
Double.isFinite(double).value - the value to testpublic static boolean isIdentity(Transform transform)
transform - which transform to test (not null, unaffected)public static boolean isOdd(int iValue)
iValue - the value to be testedpublic static float lerp(float t,
float y0,
float y1)
No rounding error is introduced when y0==y1.
t - the weight given to y1y0 - the function value at t=0y1 - the function value at t=1public static int log2(int iValue)
iValue - the input value (≥1)(1 << N) <= iValue
(≥0, ≤30)public static float max(float... fValues)
fValues - the input valuesMath.max(float, float)public static int maxInt(int... iValues)
iValues - the input valuesCollections.max(java.util.Collection),
Math.max(int, int)public static float mid(float a,
float b,
float c)
a - the first input valueb - the 2nd input valuec - the 3rd input valuepublic static float min(float... fValues)
fValues - the input valuesMath.min(float, float)public static int modulo(int iValue,
int modulus)
This differs from remainder for negative input values. For instance, modulo(-1, 4) == 3, while -1 % 4 == -1.
iValue - the input valuemodulus - (>0)public static float modulo(float fValue,
float modulus)
This differs from remainder for negative input values. For instance, modulo(-1f, 4f) == 3f, while -1f % 4f == -1f.
fValue - the input valuemodulus - (>0)public static float standardize(float fValue)
fValue - input valuepublic static float standardizeAngle(float angle)
angle - the input angle (in radians)public static double sumOfSquares(float... fValues)
fValues - the input valuespublic static float toDegrees(float radians)
radians - input angleMath.toDegrees(double)public static float toRadians(float degrees)
degrees - input angleMath.toRadians(double)public static Vector3f transform(Transform transform, Vector3f input, Vector3f storeResult)
It is safe for input and storeResult to be the same
object.
This method works on transforms containing non-normalized quaternions.
transform - the transform to apply (not null, unaffected unless
storeResult is its translation or scaling component)input - the input vector (not null, unaffected unless it's
storeResult)storeResult - storage for the result (modified if not null)storeResult or a new
instance)public static Triangle transformInverse(Transform transform, Triangle input, Triangle storeResult)
It is safe for input and storeResult to be the same
object.
transform - the transform to apply (not null, unaffected)input - the input triangle (not null, unaffected unless it's
storeResult)storeResult - storage for the result (modified if not null)storeResult or a new
instance)public static Vector3f transformInverse(Transform transform, Vector3f input, Vector3f storeResult)
It is safe for input and storeResult to be the same
object.
This method works on transforms containing non-normalized quaternions.
transform - the transform to un-apply (not null, unaffected unless
storeResult is its translation or scaling component)input - the input vector (not null, unaffected unless it's
storeResult)storeResult - storage for the result (modified if not null)storeResult or a new
instance)