|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openmali.FastMath
public class FastMath
The FastMath class provides fast and optimized mathematical functions.
| Nested Class Summary | |
|---|---|
static class |
FastMath.FRExpResultf
Helper class to return result tuple of frexp() |
| Field Summary | |
|---|---|
static float |
DEG_TO_RAD
|
static float |
E
|
static float |
INV_PI
|
static float |
INV_TWO_PI
|
static float |
LOG10_TO_LOG2
|
static double |
LOG10_TO_LOG2d
|
static float |
PI
|
static float |
PI_HALF
|
protected static int |
precision
|
static float |
RAD_TO_DEG
|
static float |
TWO_PI
|
| Constructor Summary | |
|---|---|
FastMath()
|
|
| Method Summary | |
|---|---|
static float |
acos(float x)
|
static float |
asin(float x)
|
static float |
atan(float x)
|
static float |
atan2(float y,
float x)
|
static float |
cbrt(float x)
|
static float |
ceil(float x)
|
static float |
cos(float x)
|
static float |
cosh(float x)
|
static boolean |
epsilonEquals(float v1,
float v2,
float epsilon)
|
static float |
floor(float x)
|
static FastMath.FRExpResultf |
frexp(float value)
An implementation of the C standard library frexp() function. |
static FastMath.FRExpResultf |
frexp(float value,
FastMath.FRExpResultf result)
An implementation of the C standard library frexp() function. |
static int |
getPrecision()
|
static java.util.Random |
getRandom()
Gets the Random generator. |
static float |
hypot(float a,
float b)
sqrt(a^2 + b^2) without under/overflow. |
static float |
invSqrt(float x)
|
static float |
log(float x)
|
static float |
log10(float x)
|
static float |
log1p(float x)
|
static float |
log2(float x)
|
static float |
pow(float base,
float exp)
|
static int |
pow(int base,
int exp)
|
static float |
pow2(float base)
|
static float |
pow3(float base)
|
static float |
randomFloat()
Returns the next pseudorandom, uniformly distributed float
value between 0.0 and 1.0 from this random
number generator's sequence. |
static float |
randomFloat(float max)
Generates the next random float (minimum: 0 inclusive). |
static float |
randomFloat(float min,
float max)
Generates the next random float. |
static int |
randomInt()
Generates the next random int (minimum: 0 inclusive, maximum: Integer.MAX_VALUE exclusive). |
static int |
randomInt(int max)
Generates the next random int (minimum: 0 inclusive). |
static int |
randomInt(int min,
int max)
Generates the next random int. |
static long |
randomLong()
Generates the next random long (minimum: 0 inclusive, maximum: Long.MAX_VALUE exclusive). |
static long |
randomLong(long max)
Generates the next random long (minimum: 0 inclusive). |
static long |
randomLong(long min,
long max)
Generates the next random long. |
static void |
setPrecision(int precision)
|
static float |
sin(float x)
|
static float |
sinh(float x)
|
static float |
sqrt(float x)
|
static float |
tan(float x)
|
static float |
tanh(float x)
|
static float |
toDeg(float x)
|
static float |
toRad(float x)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final float PI
public static final float PI_HALF
public static final float TWO_PI
public static final float INV_PI
public static final float INV_TWO_PI
public static final float E
public static final float DEG_TO_RAD
public static final float RAD_TO_DEG
public static final double LOG10_TO_LOG2d
public static final float LOG10_TO_LOG2
protected static int precision
| Constructor Detail |
|---|
public FastMath()
| Method Detail |
|---|
public static final void setPrecision(int precision)
public static final int getPrecision()
public static final float sin(float x)
public static final float asin(float x)
public static final float sinh(float x)
public static final float cos(float x)
public static final float acos(float x)
public static final float cosh(float x)
public static final float tan(float x)
public static final float atan(float x)
public static final float atan2(float y,
float x)
public static final float tanh(float x)
public static final float cbrt(float x)
public static final float sqrt(float x)
public static final float invSqrt(float x)
public static final float ceil(float x)
public static final float floor(float x)
public static final float log(float x)
x -
Math.log(double)public static final float log10(float x)
public static final float log1p(float x)
public static final float log2(float x)
x -
public static final float toDeg(float x)
public static final float toRad(float x)
public static final float pow(float base,
float exp)
public static final float pow2(float base)
public static final float pow3(float base)
public static final int pow(int base,
int exp)
public static final boolean epsilonEquals(float v1,
float v2,
float epsilon)
public static final float hypot(float a,
float b)
public static final FastMath.FRExpResultf frexp(float value,
FastMath.FRExpResultf result)
value - the number to splitresult -
public static final FastMath.FRExpResultf frexp(float value)
value - the number to split
public static final java.util.Random getRandom()
public static final float randomFloat()
float
value between 0.0 and 1.0 from this random
number generator's sequence. The general contract of nextFloat is that one float value, chosen (approximately) uniformly from the range 0.0f (inclusive) to 1.0f (exclusive), is pseudorandomly generated and returned. All 224 possible float values of the form m x 2-24, where m is a positive integer less than 224 , are produced with (approximately) equal probability. The method nextFloat is implemented by class Random as follows:
public float nextFloat() {
return next(24) / ((float)(1 << 24));
}
The hedge "approximately" is used in the foregoing description only
because the next method is only approximately an unbiased source of
independently chosen bits. If it were a perfect source or randomly
chosen bits, then the algorithm shown would choose float
values from the stated range with perfect uniformity.[In early versions of Java, the result was incorrectly calculated as:
This might seem to be equivalent, if not better, but in fact it introduced a slight nonuniformity because of the bias in the rounding of floating-point numbers: it was slightly more likely that the low-order bit of the significand would be 0 than that it would be 1.]return next(30) / ((float)(1 << 30));
float
value between 0.0 and 1.0 from this
random number generator's sequence.public static final float randomFloat(float max)
max - the maximum number (exclusive)
public static final float randomFloat(float min,
float max)
min - the minimum number (inclusive)max - the maximum number (exclusive)
public static final int randomInt()
public static final int randomInt(int max)
max - the maximum number (exclusive)
public static final int randomInt(int min,
int max)
min - the minimum number (inclusive)max - the maximum number (exclusive)
public static final long randomLong()
public static final long randomLong(long max)
max - the maximum number (exclusive)
public static final long randomLong(long min,
long max)
min - the minimum number (inclusive)max - the maximum number (exclusive)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||