CesiumMath
Math functions.
Source:
Core/Math.js, line 18
Members
-
staticconstantCesiumMath.DEGREES_PER_RADIAN :Number
-
The number of degrees in a radian.
-
Default Value:
- czm_degreesPerRadian
180.0 / Math.PI
See:
Source: Core/Math.js, line 379 -
staticconstantCesiumMath.EPSILON1 :Number
-
0.1Source: Core/Math.js, line 25
-
staticconstantCesiumMath.EPSILON2 :Number
-
0.01Source: Core/Math.js, line 32
-
staticconstantCesiumMath.EPSILON3 :Number
-
0.001Source: Core/Math.js, line 39
-
staticconstantCesiumMath.EPSILON4 :Number
-
0.0001Source: Core/Math.js, line 46
-
staticconstantCesiumMath.EPSILON5 :Number
-
0.00001Source: Core/Math.js, line 53
-
staticconstantCesiumMath.EPSILON6 :Number
-
0.000001Source: Core/Math.js, line 60
-
staticconstantCesiumMath.EPSILON7 :Number
-
0.0000001Source: Core/Math.js, line 67
-
staticconstantCesiumMath.EPSILON8 :Number
-
0.00000001Source: Core/Math.js, line 74
-
staticconstantCesiumMath.EPSILON9 :Number
-
0.000000001Source: Core/Math.js, line 81
-
staticconstantCesiumMath.EPSILON10 :Number
-
0.0000000001Source: Core/Math.js, line 88
-
staticconstantCesiumMath.EPSILON11 :Number
-
0.00000000001Source: Core/Math.js, line 95
-
staticconstantCesiumMath.EPSILON12 :Number
-
0.000000000001Source: Core/Math.js, line 102
-
staticconstantCesiumMath.EPSILON13 :Number
-
0.0000000000001Source: Core/Math.js, line 109
-
staticconstantCesiumMath.EPSILON14 :Number
-
0.00000000000001Source: Core/Math.js, line 116
-
staticconstantCesiumMath.EPSILON15 :Number
-
0.000000000000001Source: Core/Math.js, line 123
-
staticconstantCesiumMath.EPSILON16 :Number
-
0.0000000000000001Source: Core/Math.js, line 130
-
staticconstantCesiumMath.EPSILON17 :Number
-
0.00000000000000001Source: Core/Math.js, line 137
-
staticconstantCesiumMath.EPSILON18 :Number
-
0.000000000000000001Source: Core/Math.js, line 144
-
staticconstantCesiumMath.EPSILON19 :Number
-
0.0000000000000000001Source: Core/Math.js, line 151
-
staticconstantCesiumMath.EPSILON20 :Number
-
0.00000000000000000001Source: Core/Math.js, line 158
-
staticconstantCesiumMath.GRAVITATIONALPARAMETER :Number
-
3.986004418e14Source: Core/Math.js, line 165
-
staticconstantCesiumMath.LUNAR_RADIUS :Number
-
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.Source: Core/Math.js, line 181
-
staticconstantCesiumMath.ONE_OVER_PI :Number
-
1/pi
- czm_oneOverPi
See:
Source: Core/Math.js, line 296 -
staticconstantCesiumMath.ONE_OVER_TWO_PI :Number
-
1/2pi
- czm_oneOverTwoPi
See:
Source: Core/Math.js, line 359 -
staticconstantCesiumMath.PI :Number
-
pi
- czm_pi
See:
Source: Core/Math.js, line 287 -
staticconstantCesiumMath.PI_OVER_FOUR :Number
-
pi/4
- czm_piOverFour
See:
Source: Core/Math.js, line 323 -
staticconstantCesiumMath.PI_OVER_SIX :Number
-
pi/6
- czm_piOverSix
See:
Source: Core/Math.js, line 332 -
staticconstantCesiumMath.PI_OVER_THREE :Number
-
pi/3
- czm_piOverThree
See:
Source: Core/Math.js, line 314 -
staticconstantCesiumMath.PI_OVER_TWO :Number
-
pi/2
- czm_piOverTwo
See:
Source: Core/Math.js, line 305 -
staticconstantCesiumMath.RADIANS_PER_ARCSECOND :Number
-
The number of radians in an arc second.
-
Default Value:
- czm_radiansPerArcSecond
CesiumMath.RADIANS_PER_DEGREE
/ 3600.0See:
Source: Core/Math.js, line 389 -
staticconstantCesiumMath.RADIANS_PER_DEGREE :Number
-
The number of radians in a degree.
-
Default Value:
- czm_radiansPerDegree
Math.PI / 180.0
See:
Source: Core/Math.js, line 369 -
staticconstantCesiumMath.SIXTY_FOUR_KILOBYTES :Number
-
64 * 1024Source: Core/Math.js, line 188
-
staticconstantCesiumMath.SOLAR_RADIUS :Number
-
Radius of the sun in meters: 6.955e8Source: Core/Math.js, line 172
-
staticconstantCesiumMath.THREE_PI_OVER_TWO :Number
-
3pi/2
- czm_threePiOver2
See:
Source: Core/Math.js, line 341 -
staticconstantCesiumMath.TWO_PI :Number
-
2pi
- czm_twoPi
See:
Source: Core/Math.js, line 350
Methods
-
staticCesiumMath.clamp(value, min, max)
-
Constraint a value to lie between two values.
Name Type Description value
Number The value to constrain. min
Number The minimum value. max
Number The maximum value. Returns:
The value clamped so that min <= value <= max.Source: Core/Math.js, line 661 -
staticCesiumMath.convertLongitudeRange(angle) → Number
-
Converts a longitude value, in radians, to the range [
-Math.PI
,Math.PI
).Name Type Description angle
Number The longitude value, in radians, to convert to the range [ -Math.PI
,Math.PI
).Returns:
The equivalent longitude value in the range [-Math.PI
,Math.PI
).Example:
// Convert 270 degrees to -90 degrees longitude var longitude = Cesium.Math.convertLongitudeRange(Cesium.Math.toRadians(270.0));
Source: Core/Math.js, line 430 -
staticCesiumMath.cosh(value)
-
Returns the hyperbolic cosine of a {@code Number}. The hyperbolic cosine of value is defined to be (ex + e-x)/2.0 where e is Euler's number, approximately 2.71828183.
Special cases:
- If the argument is NaN, then the result is NaN.
- If the argument is infinite, then the result is positive infinity.
- If the argument is zero, then the result is {@code 1.0}.
Name Type Description value
Number The number whose hyperbolic cosine is to be returned. Returns:
The hyperbolic cosine of {@code value}.Source: Core/Math.js, line 258 -
staticCesiumMath.equalsEpsilon(left, right, epsilon) → Boolean
-
Determines if two values are equal within the provided epsilon. This is useful to avoid problems due to roundoff error when comparing floating-point values directly.
Name Type Default Description left
Number The first value to compare. right
Number The other value to compare. epsilon
Number 0.0
optional The maximum inclusive delta between left
andright
where they will be considered equal.Returns:
true
if the values are equal within the epsilon; otherwise,false
.Example:
var b = Cesium.Math.equalsEpsilon(0.0, 0.01, Cesium.Math.EPSILON2); // true var b = Cesium.Math.equalsEpsilon(0.0, 0.1, Cesium.Math.EPSILON2); // false
Source: Core/Math.js, line 506 -
staticCesiumMath.factorial(n) → Number
-
Computes the factorial of the provided number.
Name Type Description n
Number The number whose factorial is to be computed. Returns:
The factorial of the provided number or undefined if the number is less than 0.Throws:
-
DeveloperError : A number greater than or equal to 0 is required.
Example:
//Compute 7!, which is equal to 5040 var computedFactorial = Cesium.Math.factorial(7);
See:
Source: Core/Math.js, line 539 -
-
staticCesiumMath.incrementWrap(n, maximumValue, minimumValue) → Number
-
Increments a number with a wrapping to a minimum value if the number exceeds the maximum value.
Name Type Default Description n
Number optional The number to be incremented. maximumValue
Number optional The maximum incremented value before rolling over to the minimum value. minimumValue
Number 0.0
optional The number reset to after the maximum value has been exceeded. Returns:
The incremented number.Throws:
-
DeveloperError : Maximum value must be greater than minimum value.
Example:
var n = Cesium.Math.incrementWrap(5, 10, 0); // returns 6 var n = Cesium.Math.incrementWrap(10, 10, 0); // returns 0
Source: Core/Math.js, line 573 -
-
staticCesiumMath.isPowerOfTwo(n) → Boolean
-
Determines if a positive integer is a power of two.
Name Type Description n
Number The positive integer to test. Returns:
true
if the number if a power of two; otherwise,false
.Throws:
-
DeveloperError : A number greater than or equal to 0 is required.
Example:
var t = Cesium.Math.isPowerOfTwo(16); // true var f = Cesium.Math.isPowerOfTwo(20); // false
Source: Core/Math.js, line 607 -
-
staticCesiumMath.lerp(p, q, time) → Number
-
Computes the linear interpolation of two values.
Name Type Description p
Number The start value to interpolate. q
Number The end value to interpolate. time
Number The time of interpolation generally in the range [0.0, 1.0]
.Returns:
The linearly interpolated value.Example:
var n = Cesium.Math.lerp(0.0, 2.0, 0.5); // returns 1.0
Source: Core/Math.js, line 276 -
staticCesiumMath.negativePiToPi(angle) → Number
-
Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.
Name Type Description angle
Number in radians Returns:
The angle in the range ()-CesiumMath.PI
,CesiumMath.PI
).Source: Core/Math.js, line 455 -
staticCesiumMath.nextPowerOfTwo(n) → Number
-
Computes the next power-of-two integer greater than or equal to the provided positive integer.
Name Type Description n
Number The positive integer to test. Returns:
The next power-of-two integer.Throws:
-
DeveloperError : A number greater than or equal to 0 is required.
Example:
var n = Cesium.Math.nextPowerOfTwo(29); // 32 var m = Cesium.Math.nextPowerOfTwo(32); // 32
Source: Core/Math.js, line 632 -
-
staticCesiumMath.nextRandomNumber()
-
Generates a random number in the range of [0.0, 1.0) using a Mersenne twister.
Returns:
A random number in the range of [0.0, 1.0). -
staticCesiumMath.setRandomNumberSeed(seed)
-
Sets the seed used by the random number generator in
CesiumMath#nextRandomNumber
.Name Type Description seed
Number An integer used as the seed. Source: Core/Math.js, line 686 -
staticCesiumMath.sign(value) → Number
-
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.
Name Type Description value
Number The value to return the sign of. Returns:
The sign of value.Source: Core/Math.js, line 198 -
staticCesiumMath.sinh(value)
-
Returns the hyperbolic sine of a {@code Number}. The hyperbolic sine of value is defined to be (ex - e-x)/2.0 where e is Euler's number, approximately 2.71828183.
Special cases:
- If the argument is NaN, then the result is NaN.
- If the argument is infinite, then the result is an infinity with the same sign as the argument.
- If the argument is zero, then the result is a zero with the same sign as the argument.
Name Type Description value
Number The number whose hyperbolic sine is to be returned. Returns:
The hyperbolic sine of {@code value}.Source: Core/Math.js, line 231 -
staticCesiumMath.toDegrees(radians) → Number
-
Converts radians to degrees.
Name Type Description radians
Number The angle to convert in radians. Returns:
The corresponding angle in degrees.Source: Core/Math.js, line 410 -
staticCesiumMath.toRadians(degrees) → Number
-
Converts degrees to radians.
Name Type Description degrees
Number The angle to convert in degrees. Returns:
The corresponding angle in radians.Source: Core/Math.js, line 396 -
staticCesiumMath.zeroToTwoPi(angle) → Number
-
Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.
Name Type Description angle
Number in radians Returns:
The angle in the range (0 ,CesiumMath.TWO_PI
).Source: Core/Math.js, line 481