成员 Members
以弧度表示的度数。 The number of degrees in a radian.
0.1
0.01
0.001
0.0001
0.00001
0.000001
0.0000001
0.00000001
0.000000001
0.0000000001
0.00000000001
0.000000000001
0.0000000000001
0.00000000000001
0.000000000000001
0.0000000000000001
0.00000000000000001
0.000000000000000001
0.0000000000000000001
0.00000000000000000001
0.000000000000000000001
4 * 1024 * 1024 * 1024
WGS84 模型定义的地球引力参数(以米立方每秒平方为单位):3.986004418e14 The gravitational parameter of the Earth in meters cubed per second squared as defined by the WGS84 model: 3.986004418e14
月球的平均半径,根据“IAU/IAG 行星和卫星制图坐标和旋转要素工作组的报告:2000 年”,Celestial Mechanics 82:83-110,2002 年。 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.
1/pi
1/2pi
pi
pi/4
pi/6
pi/3
pi/2
一弧秒的弧度数。 The number of radians in an arc second.
度数的弧度数。 The number of radians in a degree.
64 * 1024
太阳半径(米):6.955e8 Radius of the sun in meters: 6.955e8
3pi/2
2pi
方法 Methods
Computes
Math.acos(value),但首先夹住 , but first clamps value 范围 [-1.0, 1.0] 以便该函数永远不会返回 NaN。 to the range [-1.0, 1.0] so that the function will never return NaN.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
value |
number | 计算 acos 的值。 The value for which to compute acos. |
返回: Returns:
如果值在 [-1.0, 1.0] 范围内,则为该值的 acos;如果该值在该范围之外,则为 -1.0 或 1.0(以较接近者为准)的 acos。 The acos of the value if the value is in the range [-1.0, 1.0], or the acos of -1.0 or 1.0, whichever is closer, if the value is outside the range.
Computes
Math.asin(value),但首先夹住 , but first clamps value 范围 [-1.0, 1.0] 以便该函数永远不会返回 NaN。 to the range [-1.0, 1.0] so that the function will never return NaN.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
value |
number | 要计算的值 asin。 The value for which to compute asin. |
返回: Returns:
如果值在 [-1.0, 1.0] 范围内,则为该值的 asin;如果该值在该范围之外,则为 -1.0 或 1.0(以较接近者为准)的 asin。 The asin of the value if the value is in the range [-1.0, 1.0], or the asin of -1.0 or 1.0, whichever is closer, if the value is outside the range.
求一个数的立方根。如果返回 NaN Finds the cube root of a number. Returns NaN if
number 未提供。 is not provided.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
number |
number | 可选 optional 号码。 The number. |
返回: Returns:
结果。 The result.
给定圆的半径和两点之间的角度,计算两点之间的弦长。 Finds the chord length between two points given the circle's radius and the angle between the points.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
angle |
number | 两点之间的角度。 The angle between the two points. |
radius |
number | 圆的半径。 The radius of the circle. |
返回: Returns:
弦长。 The chord length.
将一个值限制在两个值之间。 Constraint a value to lie between two values.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
value |
number | 要钳位的值。 The value to clamp. |
min |
number | 最小值。 The minimum value. |
max |
number | 最大值。 The maximum value. |
返回: Returns:
钳位值使得最小值 The clamped value such that min <= result <= max.
将纬度值(以弧度表示)限制在范围 [ 的便利函数 Convenience function that clamps a latitude value, in radians, to the range [
-Math.PI/2, Math.PI/2)。对于在需要正确范围的对象中使用之前清理数据很有用。 ). Useful for sanitizing data before use in objects requiring correct range.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
angle |
number |
纬度值(以弧度为单位),限制在范围 [ The latitude value, in radians, to clamp to the range [-Math.PI/2, Math.PI/2). |
返回: Returns:
纬度值限制在范围 [ The latitude value clamped to the range [
-Math.PI/2, Math.PI/2).
示例: Example:
// Clamp 108 degrees latitude to 90 degrees latitude
const latitude = Cesium.Math.clampToLatitudeRange(Cesium.Math.toRadians(108.0));
将经度值(以弧度为单位)转换为范围 [ 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
const longitude = Cesium.Math.convertLongitudeRange(Cesium.Math.toRadians(270.0));
返回数字的双曲余弦。双曲余弦 Returns the hyperbolic cosine of a number. The hyperbolic cosine of value 定义为 ( is defined to be (ex+ e + e-x)/2.0 其中 )/2.0 where e 是欧拉数,大约为 2.71828183。 is Euler's number, approximately 2.71828183.
特殊情况: Special cases:
- 如果参数为 NaN,则结果为 NaN。 If the argument is NaN, then the result is NaN.
- 如果参数是无穷大,则结果是正无穷大。 If the argument is infinite, then the result is positive infinity.
- 如果参数为零,则结果为 1.0。 If the argument is zero, then the result is 1.0.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
value |
number | 要返回双曲余弦的数字。 The number whose hyperbolic cosine is to be returned. |
返回: Returns:
双曲余弦 The hyperbolic cosine of
value.
使用绝对或相对容差测试确定两个值是否相等。这对于避免直接比较浮点值时由于舍入误差引起的问题很有用。首先使用绝对容差测试对这些值进行比较。如果失败,则执行相对容差测试。如果您不确定左和右的大小,请使用此测试。 Determines if two values are equal using an absolute or relative tolerance test. This is useful to avoid problems due to roundoff error when comparing floating-point values directly. The values are first compared using an absolute tolerance test. If that fails, a relative tolerance test is performed. Use this test if you are unsure of the magnitudes of left and right.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
left |
number | 要比较的第一个值。 The first value to compare. | |
right |
number | 要比较的其他值。 The other value to compare. | |
relativeEpsilon |
number |
0
|
可选 optional
之间的最大包含增量 The maximum inclusive delta between left and right 用于相对耐受性测试。 for the relative tolerance test. |
absoluteEpsilon |
number |
relativeEpsilon
|
可选 optional
之间的最大包含增量 The maximum inclusive delta between left and right 用于绝对耐受性测试。 for the absolute tolerance test. |
返回: Returns:
true 如果值在 epsilon 内相等;否则, if the values are equal within the epsilon; otherwise, false.
示例: Example:
const a = Cesium.Math.equalsEpsilon(0.0, 0.01, Cesium.Math.EPSILON2); // true
const b = Cesium.Math.equalsEpsilon(0.0, 0.1, Cesium.Math.EPSILON2); // false
const c = Cesium.Math.equalsEpsilon(3699175.1634344, 3699175.2, Cesium.Math.EPSILON7); // true
const d = Cesium.Math.equalsEpsilon(3699175.1634344, 3699175.2, Cesium.Math.EPSILON9); // false
计算所提供数字的阶乘。 Computes the factorial of the provided number.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
n |
number | 要计算其阶乘的数字。 The number whose factorial is to be computed. |
返回: Returns:
所提供数字的阶乘,如果数字小于 0,则未定义。 The factorial of the provided number or undefined if the number is less than 0.
抛出: Throws:
-
DeveloperError : 需要大于或等于 0 的数字。 : A number greater than or equal to 0 is required.
示例: Example:
//Compute 7!, which is equal to 5040
const computedFactorial = Cesium.Math.factorial(7);
另见: See:
计算 [-1, 1] 范围内输入的 Atan 快速近似值。基于 ShaderFastLibs 中的 Michal Drobot 近似值,而该近似值又基于“反正切函数的高效近似值”,Rajan, S. Sichun Wang Inkol, R. Joyal, A.,2006 年 5 月。根据 MIT 许可改编自 ShaderFastLibs。 Computes a fast approximation of Atan for input in the range [-1, 1]. Based on Michal Drobot's approximation from ShaderFastLibs, which in turn is based on "Efficient approximations for the arctangent function," Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006. Adapted from ShaderFastLibs under MIT License.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
x |
number | [-1, 1] 范围内的输入数字 An input number in the range [-1, 1] |
返回: Returns:
atan(x) 的近似值 An approximation of atan(x)
计算任意输入标量的 Atan2(x, y) 的快速近似值。基于 nvidia 的 cg 参考实现的范围缩减数学:http://developer.download.nvidia.com/cg/atan2.html Computes a fast approximation of Atan2(x, y) for arbitrary input scalars. Range reduction math based on nvidia's cg reference implementation: http://developer.download.nvidia.com/cg/atan2.html
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
x |
number | 如果 y 为零,则输入数字不为零。 An input number that isn't zero if y is zero. |
y |
number | 如果 x 为零,则输入数字不为零。 An input number that isn't zero if x is zero. |
返回: Returns:
atan2(x, y) 的近似值 An approximation of atan2(x, y)
将 [0, rangeMaximum] 范围内的 SNORM 值转换为 [-1.0, 1.0] 范围内的标量。 Converts a SNORM value in the range [0, rangeMaximum] to a scalar in the range [-1.0, 1.0].
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
value |
number | SNORM 值范围 [0, rangeMaximum] SNORM value in the range [0, rangeMaximum] | |
rangeMaximum |
number |
255
|
可选 optional SNORM 范围内的最大值,默认为 255。 The maximum value in the SNORM range, 255 by default. |
返回: Returns:
范围 [-1.0, 1.0] 内的标量。 Scalar in the range [-1.0, 1.0].
- CesiumMath.toSNorm
另见: See:
确定左侧值是否大于右侧值。如果两个值在范围内 Determines if the left value is greater the right value. If the two values are within
absoluteEpsilon 如果彼此相等,则它们被认为是相等的并且该函数返回 false。 of each other, they are considered equal and this function returns false.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
left |
number | 要比较的第一个数字。 The first number to compare. |
right |
number | 要比较的第二个数字。 The second number to compare. |
absoluteEpsilon |
number | 用于比较的绝对 epsilon。 The absolute epsilon to use in comparison. |
返回: Returns:
true if left 大于 is greater than right 超过 by more than
absoluteEpsilon. false if left is less or if the two
values are nearly equal.
Determines if the left value is greater than or equal to the right value. If the two values are within
absoluteEpsilon of each other, they are considered equal and this function returns true.
| Name | Type | Description |
|---|---|---|
left |
number | The first number to compare. |
right |
number | The second number to compare. |
absoluteEpsilon |
number | The absolute epsilon to use in comparison. |
Returns:
true if left is greater than right or if the
the values are nearly equal.
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:
const n = Cesium.Math.incrementWrap(5, 10, 0); // returns 6
const m = Cesium.Math.incrementWrap(10, 10, 0); // returns 0
Determines if a non-negative integer is a power of two.
The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript.
| Name | Type | Description |
|---|---|---|
n |
number | The integer to test in the range [0, (2^32)-1]. |
Returns:
true if the number if a power of two; otherwise, false.
Throws:
-
DeveloperError : A number between 0 and (2^32)-1 is required.
Example:
const t = Cesium.Math.isPowerOfTwo(16); // true
const f = Cesium.Math.isPowerOfTwo(20); // false
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:
const n = Cesium.Math.lerp(0.0, 2.0, 0.5); // returns 1.0
Determines if the left value is less than the right value. If the two values are within
absoluteEpsilon of each other, they are considered equal and this function returns false.
| Name | Type | Description |
|---|---|---|
left |
number | The first number to compare. |
right |
number | The second number to compare. |
absoluteEpsilon |
number | The absolute epsilon to use in comparison. |
Returns:
true if left is less than right by more than
absoluteEpsilon. false if left is greater or if the two
values are nearly equal.
Determines if the left value is less than or equal to the right value. If the two values are within
absoluteEpsilon of each other, they are considered equal and this function returns true.
| Name | Type | Description |
|---|---|---|
left |
number | The first number to compare. |
right |
number | The second number to compare. |
absoluteEpsilon |
number | The absolute epsilon to use in comparison. |
Returns:
true if left is less than right or if the
the values are nearly equal.
Finds the base 2 logarithm of a number.
| Name | Type | Description |
|---|---|---|
number |
number | The number. |
Returns:
The result.
Finds the logarithm of a number to a base.
| Name | Type | Description |
|---|---|---|
number |
number | The number. |
base |
number | The base. |
Returns:
The result.
The modulo operation that also works for negative dividends.
| Name | Type | Description |
|---|---|---|
m |
number | The dividend. |
n |
number | The divisor. |
Returns:
The remainder.
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 [
-CesiumMath.PI, CesiumMath.PI].
Computes the next power-of-two integer greater than or equal to the provided non-negative integer.
The maximum allowed input is 2^31 due to 32-bit bitwise operator limitation in Javascript.
| Name | Type | Description |
|---|---|---|
n |
number | The integer to test in the range [0, 2^31]. |
Returns:
The next power-of-two integer.
Throws:
-
DeveloperError : A number between 0 and 2^31 is required.
Example:
const n = Cesium.Math.nextPowerOfTwo(29); // 32
const m = Cesium.Math.nextPowerOfTwo(32); // 32
Generates a random floating point 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).
- CesiumMath.setRandomNumberSeed
- Mersenne twister on Wikipedia
See:
Converts a scalar value in the range [rangeMinimum, rangeMaximum] to a scalar in the range [0.0, 1.0]
| Name | Type | Description |
|---|---|---|
value |
number | The scalar value in the range [rangeMinimum, rangeMaximum] |
rangeMinimum |
number | The minimum value in the mapped range. |
rangeMaximum |
number | The maximum value in the mapped range. |
Returns:
A scalar value, where rangeMinimum maps to 0.0 and rangeMaximum maps to 1.0.
Computes the previous power-of-two integer less than or equal to the provided non-negative integer.
The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript.
| Name | Type | Description |
|---|---|---|
n |
number | The integer to test in the range [0, (2^32)-1]. |
Returns:
The previous power-of-two integer.
Throws:
-
DeveloperError : A number between 0 and (2^32)-1 is required.
Example:
const n = Cesium.Math.previousPowerOfTwo(29); // 16
const m = Cesium.Math.previousPowerOfTwo(32); // 32
Generates a random number between two numbers.
| Name | Type | Description |
|---|---|---|
min |
number | The minimum value. |
max |
number | The maximum value. |
Returns:
A random number between the min and max.
Sets the seed used by the random number generator
in
CesiumMath#nextRandomNumber.
| Name | Type | Description |
|---|---|---|
seed |
number | An integer used as the seed. |
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.
Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative.
This is similar to
CesiumMath#sign except that returns 1.0 instead of
0.0 when the input value is 0.0.
| Name | Type | Description |
|---|---|---|
value |
number | The value to return the sign of. |
Returns:
The sign of value.
Returns the hyperbolic sine of a 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
value.
Converts radians to degrees.
| Name | Type | Description |
|---|---|---|
radians |
number | The angle to convert in radians. |
Returns:
The corresponding angle in degrees.
Converts degrees to radians.
| Name | Type | Description |
|---|---|---|
degrees |
number | The angle to convert in degrees. |
Returns:
The corresponding angle in radians.
Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMaximum]
| Name | Type | Default | Description |
|---|---|---|---|
value |
number | The scalar value in the range [-1.0, 1.0] | |
rangeMaximum |
number |
255
|
optional The maximum value in the mapped range, 255 by default. |
Returns:
A SNORM value, where 0 maps to -1.0 and rangeMaximum maps to 1.0.
- CesiumMath.fromSNorm
See:
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 [0,
CesiumMath.TWO_PI].
