CesiumMath
Math functions.
Source:
Members
-
<static, constant> DEGREES_PER_RADIAN :Number
-
The number of degrees in a radian.
- Default Value:
- 180.0 / Math.PI
See:
-
<static, constant> EPSILON1 :Number
-
0.1
-
<static, constant> EPSILON10 :Number
-
0.0000000001
-
<static, constant> EPSILON11 :Number
-
0.00000000001
-
<static, constant> EPSILON12 :Number
-
0.000000000001
-
<static, constant> EPSILON13 :Number
-
0.0000000000001
-
<static, constant> EPSILON14 :Number
-
0.00000000000001
-
<static, constant> EPSILON15 :Number
-
0.000000000000001
-
<static, constant> EPSILON16 :Number
-
0.0000000000000001
-
<static, constant> EPSILON17 :Number
-
0.00000000000000001
-
<static, constant> EPSILON18 :Number
-
0.000000000000000001
-
<static, constant> EPSILON19 :Number
-
0.0000000000000000001
-
<static, constant> EPSILON2 :Number
-
0.01
-
<static, constant> EPSILON20 :Number
-
0.00000000000000000001
-
<static, constant> EPSILON3 :Number
-
0.001
-
<static, constant> EPSILON4 :Number
-
0.0001
-
<static, constant> EPSILON5 :Number
-
0.00001
-
<static, constant> EPSILON6 :Number
-
0.000001
-
<static, constant> EPSILON7 :Number
-
0.0000001
-
<static, constant> EPSILON8 :Number
-
0.00000001
-
<static, constant> EPSILON9 :Number
-
0.000000001
-
<static, constant> GRAVITATIONALPARAMETER :Number
-
3.986004418e14
-
<static, constant> ONE_OVER_PI :Number
-
1/pi
See:
-
<static, constant> ONE_OVER_TWO_PI :Number
-
1/2pi
See:
-
<static, constant> PI :Number
-
pi
See:
-
<static, constant> PI_OVER_FOUR :Number
-
pi/4
See:
-
<static, constant> PI_OVER_SIX :Number
-
pi/6
See:
-
<static, constant> PI_OVER_THREE :Number
-
pi/3
See:
-
<static, constant> PI_OVER_TWO :Number
-
pi/2
See:
-
<static, constant> RADIANS_PER_ARCSECOND :Number
-
The number of radians in an arc second.
- Default Value:
- CesiumMath.RADIANS_PER_DEGREE / 3600.0
- czm_radiansPerArcSecond
See:
-
<static, constant> RADIANS_PER_DEGREE :Number
-
The number of radians in a degree.
- Default Value:
- Math.PI / 180.0
See:
-
<static, constant> SIXTY_FOUR_KILOBYTES :Number
-
64 * 1024
-
<static, constant> SOLAR_RADIUS :Number
-
Radius of the sun in meters: 6.995e8
-
<static, constant> THREE_PI_OVER_TWO :Number
-
3pi/2
See:
-
<static, constant> TWO_PI :Number
-
2pi
See:
Methods
-
<static> clamp
-
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> convertLongitudeRange
-
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> cosh
-
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> equalsEpsilon
-
DOC_TBA
-
<static> factorial
-
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> incrementWrap
-
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> isPowerOfTwo
-
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:
Booleantrue
if the number if a power of two; otherwise,false
.Example
var t = CesiumMath.isPowerOfTwo(16); // true var f = CesiumMath.isPowerOfTwo(20); // false
-
<static> lerp
-
DOC_TBA
-
<static> negativePiToPi
-
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> sign
-
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> sinh
-
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> toDegrees
-
Converts radians to degrees.
Parameters:
Name Type Description radians
Number The angle to convert in radians. Returns:
Number The corresponding angle in degrees. -
<static> toRadians
-
Converts degrees to radians.
Parameters:
Name Type Description degrees
Number The angle to convert in degrees. Returns:
Number The corresponding angle in radians. -
<static> zeroToTwoPi
-
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
).