|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.threerings.math.FloatMath
public class FloatMath
Utility methods and constants for single-precision floating point math.
| Field Summary | |
|---|---|
static float |
E
The base value of the natural logarithm. |
static float |
EPSILON
A small number. |
static float |
HALF_PI
Pi times one half. |
static float |
PI
The ratio of a circle's circumference to its diameter. |
static float |
TWO_PI
The circle constant, tau (τ) http://tauday.com/ |
| Constructor Summary | |
|---|---|
FloatMath()
|
|
| Method Summary | |
|---|---|
static float |
acos(float a)
Computes and returns the arc cosine of the given value. |
static float |
asin(float a)
Computes and returns the arc sine of the given value. |
static float |
atan(float a)
Computes and returns the arc tangent of the given value. |
static float |
atan2(float y,
float x)
Computes and returns the arc tangent of the given values. |
static float |
cbrt(float v)
Returns the cube root of the supplied value. |
static float |
ceil(float v)
Returns the ceiling of v. |
static float |
clamp(float v,
float lower,
float upper)
Clamps a value to the range [lower, upper]. |
static float |
cos(float a)
Computes and returns the cosine of the given angle. |
static boolean |
epsilonEquals(float v1,
float v2)
Determines whether two values are "close enough" to equal. |
static float |
exp(float v)
Returns e to the power of the supplied value. |
static float |
exponential(float mean)
Returns a random value according to the exponential distribution with the provided mean. |
static float |
floor(float v)
Returns the floor of v. |
static float |
getAngularDifference(float a1,
float a2)
Returns the (shortest) difference between two angles, assuming that both angles are in [-pi, +pi]. |
static float |
getAngularDistance(float a1,
float a2)
Returns the (shortest) distance between two angles, assuming that both angles are in [-pi, +pi]. |
static float |
hypot(float x,
float y)
Computes and returns sqrt(x*x + y*y). |
static int |
iceil(float v)
Returns the ceiling of v as an integer without calling the relatively expensive Math.ceil(double). |
static float |
IEEEremainder(float f1,
float f2)
Returns the remainder when f1 is divided by f2. |
static int |
ifloor(float v)
Returns the floor of v as an integer without calling the relatively expensive Math.floor(double). |
static boolean |
isWithin(float v,
float lower,
float upper)
Checks whether the value supplied is in [lower, upper]. |
static float |
lerp(float v1,
float v2,
float t)
Linearly interpolates between v1 and v2 by the parameter t. |
static float |
lerpa(float a1,
float a2,
float t)
Linearly interpolates between two angles, taking the shortest path around the circle. |
static float |
log(float v)
Returns the natural logarithm of the supplied value. |
static float |
log10(float v)
Returns the base 10 logarithm of the supplied value. |
static float |
mirrorAngle(float a)
Returns the mirror angle of the specified angle (assumed to be in [-pi, +pi]). |
static float |
normal()
Returns a random value according to the standard normal distribution. |
static float |
normal(float mean,
float stddev)
Returns a random value according to the normal distribution with the provided mean and standard deviation. |
static float |
normalizeAngle(float a)
Returns an angle in the range [-pi, pi]. |
static float |
normalizeAnglePositive(float a)
Returns an angle in the range [0, 2pi]. |
static float |
pow(float v,
float e)
Returns v to the power of e. |
static float |
random()
Returns a uniformly distributed random floating point value in [0, 1). |
static float |
random(float lower,
float upper)
Returns a uniformly distributed random floating point value in [lower, upper). |
static Vector3f |
reflect(Vector3f i,
Vector3f n)
Computes the reflection of a vector. |
static Vector3f |
reflect(Vector3f i,
Vector3f n,
Vector3f result)
Computes the reflection of a vector and stores it in the provided vector. |
static Vector3f |
refract(Vector3f i,
Vector3f n,
float eta)
Computes the refraction of a vector. |
static Vector3f |
refract(Vector3f i,
Vector3f n,
float eta,
Vector3f result)
Computes the refraction of a vector, placing the result in the provided vector. |
static int |
round(float v)
A cheaper version of Math.round(float) that doesn't handle the special cases. |
static float |
roundNearest(float v,
float target)
Rounds a value to the nearest multiple of a target. |
static float |
sin(float a)
Computes and returns the sine of the given angle. |
static float |
sqrt(float v)
Returns the square root of the supplied value. |
static float |
tan(float a)
Computes and returns the tangent of the given angle. |
static float |
toDegrees(float a)
Converts from radians to degrees. |
static float |
toRadians(float a)
Converts from degrees to radians. |
static Vector3f |
updateClosest(Vector3f origin,
Vector3f result,
Vector3f closest)
Updates the value of the closest point and returns a new result vector reference. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final float PI
public static final float TWO_PI
public static final float HALF_PI
public static final float E
public static final float EPSILON
| Constructor Detail |
|---|
public FloatMath()
| Method Detail |
|---|
public static float sin(float a)
Math.sin(double)public static float cos(float a)
Math.cos(double)public static float tan(float a)
Math.tan(double)public static float asin(float a)
Math.asin(double)public static float acos(float a)
Math.acos(double)public static float atan(float a)
Math.atan(double)
public static float atan2(float y,
float x)
Math.atan2(double, double)public static float toDegrees(float a)
Math.toDegrees(double)public static float toRadians(float a)
Math.toRadians(double)public static float sqrt(float v)
Math.sqrt(double)public static float cbrt(float v)
Math.cbrt(double)
public static float hypot(float x,
float y)
Math.hypot(double, double)public static float exp(float v)
Math.exp(double)public static float log(float v)
Math.log(double)public static float log10(float v)
Math.log10(double)
public static float pow(float v,
float e)
Math.pow(double, double)public static float floor(float v)
Math.floor(double)public static int round(float v)
Math.round(float) that doesn't handle the special cases.
public static int ifloor(float v)
Math.floor(double).
public static float ceil(float v)
Math.ceil(double)public static int iceil(float v)
Math.ceil(double).
public static float IEEEremainder(float f1,
float f2)
Math.IEEEremainder(double, double)
public static float clamp(float v,
float lower,
float upper)
public static float roundNearest(float v,
float target)
public static boolean isWithin(float v,
float lower,
float upper)
public static float random(float lower,
float upper)
public static float random()
public static float normal(float mean,
float stddev)
public static float normal()
public static float exponential(float mean)
public static float lerpa(float a1,
float a2,
float t)
public static float lerp(float v1,
float v2,
float t)
public static boolean epsilonEquals(float v1,
float v2)
public static float getAngularDistance(float a1,
float a2)
public static float getAngularDifference(float a1,
float a2)
public static float normalizeAngle(float a)
public static float normalizeAnglePositive(float a)
public static float mirrorAngle(float a)
public static Vector3f reflect(Vector3f i,
Vector3f n)
public static Vector3f reflect(Vector3f i,
Vector3f n,
Vector3f result)
public static Vector3f refract(Vector3f i,
Vector3f n,
float eta)
public static Vector3f refract(Vector3f i,
Vector3f n,
float eta,
Vector3f result)
public static Vector3f updateClosest(Vector3f origin,
Vector3f result,
Vector3f closest)
Vector3f closest = result;
for (Model model : models) {
if (model.getIntersection(ray, result)) {
result = FloatMath.updateClosest(ray.getOrigin(), result, closest);
}
}
// if result != closest, then we hit something
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||