CesiumMath

CesiumMath

Math functions.

Source:

Members

<static, constant> :Number

The number of degrees in a radian.
Default Value:
  • 180.0 / Math.PI
See:
  • czm_degreesPerRadian

<static, constant> :Number

0.1

<static, constant> :Number

0.0000000001

<static, constant> :Number

0.00000000001

<static, constant> :Number

0.000000000001

<static, constant> :Number

0.0000000000001

<static, constant> :Number

0.00000000000001

<static, constant> :Number

0.000000000000001

<static, constant> :Number

0.0000000000000001

<static, constant> :Number

0.00000000000000001

<static, constant> :Number

0.000000000000000001

<static, constant> :Number

0.0000000000000000001

<static, constant> :Number

0.01

<static, constant> :Number

0.00000000000000000001

<static, constant> :Number

0.001

<static, constant> :Number

0.0001

<static, constant> :Number

0.00001

<static, constant> :Number

0.000001

<static, constant> :Number

0.0000001

<static, constant> :Number

0.00000001

<static, constant> :Number

0.000000001

<static, constant> :Number

3.986004418e14

<static, constant> :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.

<static, constant> :Number

1/pi
See:
  • czm_oneOverPi

<static, constant> :Number

1/2pi
See:
  • czm_oneOverTwoPi

<static, constant> :Number

pi
See:
  • czm_pi

<static, constant> :Number

pi/4
See:
  • czm_piOverFour

<static, constant> :Number

pi/6
See:
  • czm_piOverSix

<static, constant> :Number

pi/3
See:
  • czm_piOverThree

<static, constant> :Number

pi/2
See:
  • czm_piOverTwo

<static, constant> :Number

The number of radians in an arc second.
Default Value:
See:
  • czm_radiansPerArcSecond

<static, constant> :Number

The number of radians in a degree.
Default Value:
  • Math.PI / 180.0
See:
  • czm_radiansPerDegree

<static, constant> :Number

64 * 1024

<static, constant> :Number

Radius of the sun in meters: 6.955e8

<static, constant> :Number

3pi/2
See:
  • czm_threePiOver2

<static, constant> :Number

2pi
See:
  • czm_twoPi

Methods

<static>

Constraint a value to lie between two values.

Parameters:
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.

<static>

Converts a longitude value, in radians, to the range [-Math.PI, Math.PI).

Parameters:
Name Type Description
angle Number The longitude value, in radians, to convert to the range [-Math.PI, Math.PI).
Returns:
Number 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));

<static>

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}.

Parameters:
Name Type Description
value The number whose hyperbolic cosine is to be returned.
Returns:
The hyperbolic cosine of {@code value}.

<static>

DOC_TBA

<static>

Computes the factorial of the provided number.

Parameters:
Name Type Description
n Number The number whose factorial is to be computed.
Throws:
DeveloperError : A number greater than or equal to 0 is required.
Returns:
Number The factorial of the provided number or undefined if the number is less than 0.
Example
//Compute 7!, which is equal to 5040
var computedFactorial = Cesium.Math.factorial(7);
See:

<static>

Increments a number with a wrapping to a minimum value if the number exceeds the maximum value.

Parameters:
Name Type Argument 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 <optional>
0.0 The number reset to after the maximum value has been exceeded.
Throws:
DeveloperError : Maximum value must be greater than minimum value.
Returns:
Number The incremented number.
Example
var n = Cesium.Math.incrementWrap(5, 10, 0); // returns 6
var n = Cesium.Math.incrementWrap(10, 10, 0); // returns 0

<static>

Determines if a positive integer is a power of two.

Parameters:
Name Type Description
n Number The positive integer to test.
Throws:
DeveloperError : A number greater than or equal to 0 is required.
Returns:
Boolean true if the number if a power of two; otherwise, false.
Example
var t = Cesium.Math.isPowerOfTwo(16); // true
var f = Cesium.Math.isPowerOfTwo(20); // false

<static>

DOC_TBA

<static>

Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.

Parameters:
Name Type Description
angle Number in radians
Returns:
Number The angle in the range ()-CesiumMath.PI, CesiumMath.PI).

<static>

Computes the next power-of-two integer greater than or equal to the provided positive integer.

Parameters:
Name Type Description
n Number The positive integer to test.
Throws:
DeveloperError : A number greater than or equal to 0 is required.
Returns:
Number The next power-of-two integer.
Example
var n = Cesium.Math.nextPowerOfTwo(29); // 32
var m = Cesium.Math.nextPowerOfTwo(32); // 32

<static>

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).
See:
  • CesiumMath#setRandomNumberSeed
  • http://en.wikipedia.org/wiki/Mersenne_twister

<static>

Sets the seed used by the random number generator in CesiumMath#nextRandomNumber.

Parameters:
Name Type Description
seed Number An integer used as the seed.

<static>

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.

Parameters:
Name Type Description
value Number The value to return the sign of.
Returns:
Number The sign of value.

<static>

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.

Parameters:
Name Type Description
value The number whose hyperbolic sine is to be returned.
Returns:
The hyperbolic sine of {@code value}.

<static>

Converts radians to degrees.

Parameters:
Name Type Description
radians Number The angle to convert in radians.
Returns:
Number The corresponding angle in degrees.

<static>

Converts degrees to radians.

Parameters:
Name Type Description
degrees Number The angle to convert in degrees.
Returns:
Number The corresponding angle in radians.

<static>

Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.

Parameters:
Name Type Description
angle Number in radians
Returns:
Number The angle in the range (0 , CesiumMath.TWO_PI).