@JsType(isNative=true, namespace="Cesium", name="Math") public class Math extends Object
Modifier and Type | Field and Description |
---|---|
static Number |
cbrt
Finds the cube root of a number.
|
Modifier and Type | Method and Description |
---|---|
static double |
acosClamped(double value)
Computes Math.acos(value), but first clamps value to the range [-1.0, 1.0] so that the function will never return NaN.
|
static double |
asinClamped(double value)
Computes Math.asin(value), but first clamps value to the range [-1.0, 1.0] so that the function will never return NaN.
|
static double |
chordLength(double angle,
double radius)
Finds the chord length between two points given the circle's radius and the angle between the points.
|
static double |
clamp(double value,
double min,
double max)
Constraint a value to lie between two values.
|
static double |
clampToLatitudeRange(double angle)
Convenience function that clamps a latitude value, in radians, to the range [-Math.PI/2, Math.PI/2).
|
static double |
convertLongitudeRange(double angle)
Converts a longitude value, in radians, to the range [-Math.PI, Math.PI).
|
static double |
cosh(double value)
Returns the hyperbolic cosine of a number.
|
static double |
DEGREES_PER_RADIAN()
The number of degrees in a radian.
|
static double |
EPSILON1()
0.1
|
static double |
EPSILON10()
0.0000000001
|
static double |
EPSILON11()
0.00000000001
|
static double |
EPSILON12()
0.000000000001
|
static double |
EPSILON13()
0.0000000000001
|
static double |
EPSILON14()
0.00000000000001
|
static double |
EPSILON15()
0.000000000000001
|
static double |
EPSILON16()
0.0000000000000001
|
static double |
EPSILON17()
0.00000000000000001
|
static double |
EPSILON18()
0.000000000000000001
|
static double |
EPSILON19()
0.0000000000000000001
|
static double |
EPSILON2()
0.01
|
static double |
EPSILON20()
0.00000000000000000001
|
static double |
EPSILON3()
0.001
|
static double |
EPSILON4()
0.0001
|
static double |
EPSILON5()
0.00001
|
static double |
EPSILON6()
0.000001
|
static double |
EPSILON7()
0.0000001
|
static double |
EPSILON8()
0.00000001
|
static double |
EPSILON9()
0.000000001
|
static boolean |
equalsEpsilon(double left,
double right,
double relativeEpsilon)
Determines if two values are equal using an absolute or relative tolerance test.
|
static boolean |
equalsEpsilon(double left,
double right,
double relativeEpsilon,
double absoluteEpsilon)
Determines if two values are equal using an absolute or relative tolerance test.
|
static double |
factorial(double n)
Computes the factorial of the provided number.
|
static double |
fromSNorm(double value)
Converts a SNORM value in the range [0, rangeMax] to a scalar in the range [-1.0, 1.0].
|
static double |
fromSNorm(double value,
double rangeMax)
Converts a SNORM value in the range [0, rangeMax] to a scalar in the range [-1.0, 1.0].
|
static double |
GRAVITATIONALPARAMETER()
3.986004418e14
|
static double |
incrementWrap(double n,
double maximumValue,
double minimumValue)
Increments a number with a wrapping to a minimum value if the number exceeds the maximum value.
|
static boolean |
isPowerOfTwo(double n)
Determines if a positive integer is a power of two.
|
static double |
lerp(double p,
double q,
double time)
Computes the linear interpolation of two values.
|
static double |
logBase(double number,
double base)
Finds the logarithm of a number to a base.
|
static double |
LUNAR_RADIUS()
The mean radius of the moon, according to the "Report of the IAU/IAG Working Group on Cartographic Coordinates and
Rotational Elements of the Planets and satellites: 2000", Celestial Mechanics 82: 83-110, 2002.
|
static double |
mod(double m,
double n)
The modulo operation that also works for negative dividends.
|
static double |
negativePiToPi(double angle)
Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.
|
static double |
nextPowerOfTwo(double n)
Computes the next power-of-two integer greater than or equal to the provided positive integer.
|
static double |
nextRandomNumber()
Generates a random number in the range of [0.0, 1.0) using a Mersenne twister.
|
static double |
normalize(double value,
double rangeMinimum,
double rangeMaximum)
Converts a scalar value in the range [rangeMinimum, rangeMaximum] to a scalar in the range [0.0, 1.0]
|
static double |
ONE_OVER_PI()
1/pi
|
static double |
ONE_OVER_TWO_PI()
1/2pi
|
static double |
PI_OVER_FOUR()
pi/4
|
static double |
PI_OVER_SIX()
pi/6
|
static double |
PI_OVER_THREE()
pi/3
|
static double |
PI_OVER_TWO()
pi/2
|
static double |
PI()
pi
|
static double |
RADIANS_PER_ARCSECOND()
The number of radians in an arc second.
|
static double |
RADIANS_PER_DEGREE()
The number of radians in a degree.
|
static double |
randomBetween(double min,
double max)
Generates a random number between two numbers.
|
static void |
setRandomNumberSeed(int seed)
Sets the seed used by the random number generator in
nextRandomNumber() . |
static double |
sign(double value)
Returns the sign of the value; 1 if the value is positive, -1 if the value is negative, or 0 if the value is 0.
|
static double |
signNotZero(double value)
Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative.
|
static double |
sinh(double value)
Returns the hyperbolic sine of a number.
|
static double |
SIXTY_FOUR_KILOBYTES()
64 * 1024
|
static double |
SOLAR_RADIUS()
Radius of the sun in meters: 6.955e8
|
static double |
THREE_PI_OVER_TWO()
3pi/2
|
static double |
toDegrees(double radians)
Converts radians to degrees.
|
static double |
toRadians(double degrees)
Converts degrees to radians.
|
static double |
toSNorm(double value)
Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMax]
|
static double |
toSNorm(double value,
double rangeMax)
Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMax]
|
static double |
TWO_PI()
2pi
|
static double |
zeroToTwoPi(double angle)
Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.
|
@JsProperty public static Number cbrt
@JsProperty(name="DEGREES_PER_RADIAN") public static double DEGREES_PER_RADIAN()
@JsProperty(name="EPSILON1") public static double EPSILON1()
@JsProperty(name="EPSILON2") public static double EPSILON2()
@JsProperty(name="EPSILON3") public static double EPSILON3()
@JsProperty(name="EPSILON4") public static double EPSILON4()
@JsProperty(name="EPSILON5") public static double EPSILON5()
@JsProperty(name="EPSILON6") public static double EPSILON6()
@JsProperty(name="EPSILON7") public static double EPSILON7()
@JsProperty(name="EPSILON8") public static double EPSILON8()
@JsProperty(name="EPSILON9") public static double EPSILON9()
@JsProperty(name="EPSILON10") public static double EPSILON10()
@JsProperty(name="EPSILON11") public static double EPSILON11()
@JsProperty(name="EPSILON12") public static double EPSILON12()
@JsProperty(name="EPSILON13") public static double EPSILON13()
@JsProperty(name="EPSILON14") public static double EPSILON14()
@JsProperty(name="EPSILON15") public static double EPSILON15()
@JsProperty(name="EPSILON16") public static double EPSILON16()
@JsProperty(name="EPSILON17") public static double EPSILON17()
@JsProperty(name="EPSILON18") public static double EPSILON18()
@JsProperty(name="EPSILON19") public static double EPSILON19()
@JsProperty(name="EPSILON20") public static double EPSILON20()
@JsProperty(name="GRAVITATIONALPARAMETER") public static double GRAVITATIONALPARAMETER()
@JsProperty(name="LUNAR_RADIUS") public static double LUNAR_RADIUS()
@JsProperty(name="ONE_OVER_PI") public static double ONE_OVER_PI()
@JsProperty(name="ONE_OVER_TWO_PI") public static double ONE_OVER_TWO_PI()
@JsProperty(name="PI") public static double PI()
@JsProperty(name="PI_OVER_FOUR") public static double PI_OVER_FOUR()
@JsProperty(name="PI_OVER_SIX") public static double PI_OVER_SIX()
@JsProperty(name="PI_OVER_THREE") public static double PI_OVER_THREE()
@JsProperty(name="PI_OVER_TWO") public static double PI_OVER_TWO()
@JsProperty(name="RADIANS_PER_ARCSECOND") public static double RADIANS_PER_ARCSECOND()
@JsProperty(name="RADIANS_PER_DEGREE") public static double RADIANS_PER_DEGREE()
@JsProperty(name="SIXTY_FOUR_KILOBYTES") public static double SIXTY_FOUR_KILOBYTES()
@JsProperty(name="SOLAR_RADIUS") public static double SOLAR_RADIUS()
@JsProperty(name="THREE_PI_OVER_TWO") public static double THREE_PI_OVER_TWO()
@JsProperty(name="TWO_PI") public static double TWO_PI()
@JsMethod public static double acosClamped(double value)
value
- The value for which to compute acos.@JsMethod public static double asinClamped(double value)
value
- The value for which to compute asin.@JsMethod public static double chordLength(double angle, double radius)
angle
- The angle between the two points.radius
- The radius of the circle.@JsMethod public static double clamp(double value, double min, double max)
value
- The value to constrain.min
- The minimum value.max
- The maximum value.@JsMethod public static double clampToLatitudeRange(double angle)
angle
- The latitude value, in radians, to clamp to the range [-Math.PI/2, Math.PI/2).
//Clamp 108 degrees latitude to 90 degrees latitude
double latitude = Math.clampToLatitudeRange(Math.toRadians(108.0));
@JsMethod public static double convertLongitudeRange(double angle)
angle
- The longitude value, in radians, to convert to the range [-Math.PI, Math.PI).
// Convert 270 degrees to -90 degrees longitude
double longitude = Math.convertLongitudeRange(Math.toRadians(270.0));
@JsMethod public static double cosh(double value)
value
- The number whose hyperbolic cosine is to be returned.@JsMethod public static boolean equalsEpsilon(double left, double right, double relativeEpsilon)
left
- The first value to compare.right
- The other value to compare.relativeEpsilon
- The maximum inclusive delta between left and right for the relative tolerance test.
boolean a = Math.equalsEpsilon(0.0, 0.01, Math.EPSILON2); // true
boolean b = Math.equalsEpsilon(0.0, 0.1, Math.EPSILON2); // false
boolean c = Math.equalsEpsilon(3699175.1634344, 3699175.2, Math.EPSILON7); // true
boolean d = Math.equalsEpsilon(3699175.1634344, 3699175.2, Math.EPSILON9); // false
@JsMethod public static boolean equalsEpsilon(double left, double right, double relativeEpsilon, double absoluteEpsilon)
Example:
boolean a = Math.equalsEpsilon(0.0, 0.01, Math.EPSILON2); // true
boolean b = Math.equalsEpsilon(0.0, 0.1, Math.EPSILON2); // false
boolean c = Math.equalsEpsilon(3699175.1634344, 3699175.2, Math.EPSILON7); // true
boolean d = Math.equalsEpsilon(3699175.1634344, 3699175.2, Math.EPSILON9); // false
left
- The first value to compare.right
- The other value to compare.relativeEpsilon
- The maximum inclusive delta between left and right for the relative tolerance test.absoluteEpsilon
- Default: relativeEpsilon. The maximum inclusive delta between left and right for the absolute tolerance test.@JsMethod public static double factorial(double n)
Example:
//Compute 7!, which is equal to 5040
double computedFactorial = Math.factorial(7);
n
- The number whose factorial is to be computed.@JsMethod public static double fromSNorm(double value)
value
- SNORM value in the range [0, 255]toSNorm(double)
@JsMethod public static double fromSNorm(double value, double rangeMax)
value
- SNORM value in the range [0, 255]rangeMax
- The maximum value in the SNORM range, 255 by default.toSNorm(double, double)
@JsMethod public static double incrementWrap(double n, double maximumValue, double minimumValue)
Example:
double n = Math.incrementWrap(5, 10, 0); // returns 6
double n = Math.incrementWrap(10, 10, 0); // returns 0
n
- The number to be incremented.maximumValue
- The maximum incremented value before rolling over to the minimum value.minimumValue
- The number reset to after the maximum value has been exceeded.@JsMethod public static boolean isPowerOfTwo(double n)
Example:
boolean t = Math.isPowerOfTwo(16); // true
boolean f = Math.isPowerOfTwo(20); // false
n
- The positive integer to test.@JsMethod public static double lerp(double p, double q, double time)
Example:
double n = Math.lerp(0.0, 2.0, 0.5); // returns 1.0
p
- The start value to interpolate.q
- The end value to interpolate.time
- The time of interpolation generally in the range [0.0, 1.0].@JsMethod public static double logBase(double number, double base)
number
- The number.base
- The base.@JsMethod public static double mod(double m, double n)
m
- The dividend.n
- The divisor.@JsMethod public static double negativePiToPi(double angle)
angle
- in radians@JsMethod public static double nextPowerOfTwo(double n)
Example:
double n = Math.nextPowerOfTwo(29); // 32
double m = Math.nextPowerOfTwo(32); // 32
n
- The positive integer to test.@JsMethod public static double nextRandomNumber()
setRandomNumberSeed(int)
,
Mersenne twister on Wikipedia@JsMethod public static double normalize(double value, double rangeMinimum, double rangeMaximum)
value
- The scalar value in the range [rangeMinimum, rangeMaximum]rangeMinimum
- The minimum value in the mapped range.rangeMaximum
- The maximum value in the mapped range.@JsMethod public static double randomBetween(double min, double max)
min
- The minimum value.max
- The maximum value.@JsMethod public static void setRandomNumberSeed(int seed)
nextRandomNumber()
.seed
- An integer used as the seed.@JsMethod public static double sign(double value)
value
- The value to return the sign of.@JsMethod public static double signNotZero(double value)
sign(double)
except that returns 1.0 instead of 0.0 when the input value is 0.0.value
- The value to return the sign of.@JsMethod public static double sinh(double value)
value
- The number whose hyperbolic sine is to be returned.@JsMethod public static double toDegrees(double radians)
radians
- The angle to convert in radians.@JsMethod public static double toRadians(double degrees)
degrees
- The angle to convert in degrees.@JsMethod public static double toSNorm(double value)
value
- The scalar value in the range [-1.0, 1.0]fromSNorm(double, double)
@JsMethod public static double toSNorm(double value, double rangeMax)
value
- The scalar value in the range [-1.0, 1.0]rangeMax
- The maximum value in the mapped range, 255 by default.fromSNorm(double, double)
@JsMethod public static double zeroToTwoPi(double angle)
angle
- in radiansCopyright © 2019. All rights reserved.