CesiumMath

CesiumMath

Math functions.

Source:

Members

<static, constant> :Number

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

<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

1/pi
See:

<static, constant> :Number

1/2pi
See:

<static, constant> :Number

pi
See:

<static, constant> :Number

pi/4
See:

<static, constant> :Number

pi/6
See:

<static, constant> :Number

pi/3
See:

<static, constant> :Number

pi/2
See:

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

<static, constant> :Number

Radius of the sun in meters: 6.995e8
Default Value:
  • 6.995e8

<static, constant> :Number

3pi/2
See:

<static, constant> :Number

2pi
See:

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 = CesiumMath.convertLongitudeRange(CesiumMath.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 = CesiumMath.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 = CesiumMath.incrementWrap(5, 10, 0); // returns 6
var n = CesiumMath.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 = CesiumMath.isPowerOfTwo(16); // true
var f = CesiumMath.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>

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