|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.nexttext.FastMath
public final class FastMath
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 double |
abs(double dValue)
Returns Absolute value of a double. |
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 double |
asin(double dValue)
Returns the arc sine of an angle given in radians. Special cases: If dValue is smaller than -1, then the result is -HALF_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 double |
atan(double dValue)
Returns the arc tangent of an angle given in radians. |
static float |
atan(float fValue)
Returns the arc tangent of an angle given in radians. |
static double |
atan2(double dY,
double dX)
A direct call to Math.atan2. |
static float |
atan2(float fY,
float fX)
A direct call to Math.atan2. |
static processing.core.PVector |
cartesianToSpherical(processing.core.PVector cartCoords,
processing.core.PVector store)
Converts a point from Cartesian coordinates (using positive Y as up) to Spherical and stores the results in the store var. |
static processing.core.PVector |
cartesianZToSpherical(processing.core.PVector cartCoords,
processing.core.PVector 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 float |
copysign(float x,
float y)
|
static double |
cos(double dValue)
Returns cos of a value. |
static float |
cos(float fValue)
Returns cos of a value. |
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 |
floor(float fValue)
Returns a number rounded down. |
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 |
LERP(float percent,
float startValue,
float endValue)
Linear interpolation from startValue to endValue by the given percent. |
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 float 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 float |
pow(float fBase,
float fExponent)
Returns a number raised to an exponent power. |
static double |
reduceSinAngle(double radians)
Fast Trig functions for x86. |
static float |
reduceSinAngle(float radians)
Fast Trig functions for x86. |
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 double |
sin(double dValue)
Returns sine of a value. |
static float |
sin(float fValue)
Returns sine of a value. |
static processing.core.PVector |
sphericalToCartesian(processing.core.PVector sphereCoords,
processing.core.PVector store)
Converts a point from Spherical coordinates to Cartesian (using positive Y as up) and stores the results in the store var. |
static processing.core.PVector |
sphericalToCartesianZ(processing.core.PVector sphereCoords,
processing.core.PVector 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 double |
sqrt(double dValue)
Returns the square root of a given value. |
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 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double DBL_EPSILON
public static final float FLT_EPSILON
public static final float ZERO_TOLERANCE
public static final float ONE_THIRD
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 INV_PI
public static final float INV_TWO_PI
public static final float DEG_TO_RAD
public static final float RAD_TO_DEG
public static final java.util.Random rand
Method Detail |
---|
public static boolean isPowerOfTwo(int number)
number
- The number to test.
public static int nearestPowerOfTwo(int number)
public static float LERP(float percent, float startValue, float endValue)
percent
- Percent value to use.startValue
- Begining value. 0% of fendValue
- ending value. 100% of f
public static float acos(float fValue)
fValue
- The angle, in radians.
Math.acos(double)
public static float asin(float fValue)
fValue
- The angle, in radians.
Math.asin(double)
public static double asin(double dValue)
dValue
- The angle, in radians.
Math.asin(double)
public static float atan(float fValue)
fValue
- The angle, in radians.
Math.atan(double)
public static double atan(double dValue)
dValue
- The angle, in radians.
Math.atan(double)
public static float atan2(float fY, float fX)
fY
- fX
-
Math.atan2(double, double)
public static double atan2(double dY, double dX)
dY
- dX
-
Math.atan2(double, double)
public static float ceil(float fValue)
fValue
- The value.
Math.ceil(double)
public static float reduceSinAngle(float radians)
public static double reduceSinAngle(double radians)
public static float sin(float fValue)
fValue
- The value to sine, in radians.
Math.sin(double)
public static double sin(double dValue)
dValue
- The value to sine, in radians.
Math.sin(double)
public static float cos(float fValue)
fValue
- The value to cosine, in radians.
Math.cos(double)
public static double cos(double dValue)
dValue
- The value to cosine, in radians.
Math.cos(double)
public static float exp(float fValue)
fValue
- Value to raise to a power.
Math.exp(double)
public static float abs(float fValue)
fValue
- The value to abs.
Math.abs(float)
public static double abs(double dValue)
dValue
- The value to abs.
Math.abs(double)
public static float floor(float fValue)
fValue
- The value to round
Math.floor(double)
public static float invSqrt(float fValue)
fValue
- The value to process.
Math.sqrt(double)
public static float log(float fValue)
fValue
- The value to log.
Math.log(double)
public static float log(float value, float base)
value
- The value to log.base
- Base of logarithm.
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 sqr(float fValue)
fValue
- The vaule to square.
public static float sqrt(float fValue)
fValue
- The value to sqrt.
Math.sqrt(double)
public static double sqrt(double dValue)
dValue
- 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 int sign(int iValue)
iValue
- The integer to examine.
public static float sign(float fValue)
fValue
- The float to examine.
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)
public static float nextRandomFloat()
public static int nextRandomInt(int min, int max)
public static int nextRandomInt()
public static processing.core.PVector sphericalToCartesian(processing.core.PVector sphereCoords, processing.core.PVector store)
public static processing.core.PVector cartesianToSpherical(processing.core.PVector cartCoords, processing.core.PVector store)
public static processing.core.PVector sphericalToCartesianZ(processing.core.PVector sphereCoords, processing.core.PVector store)
public static processing.core.PVector cartesianZToSpherical(processing.core.PVector cartCoords, processing.core.PVector store)
public static float normalize(float val, float min, float max)
val
- -
the angle to normalize (in radians)
public static float copysign(float x, float y)
x
- the value whose sign is to be adjusted.y
- the value whose sign is to be used.
public static float clamp(float input, float min, float max)
input
- min
- max
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |