Math()

Math functions.

Members

static constant Cesium.Math.DEGREES_PER_RADIAN : number

弧度数.

static constant Cesium.Math.EPSILON1 : number

0.1

static constant Cesium.Math.EPSILON2 : number

0.01

static constant Cesium.Math.EPSILON3 : number

0.001

static constant Cesium.Math.EPSILON4 : number

0.0001

static constant Cesium.Math.EPSILON5 : number

0.00001

static constant Cesium.Math.EPSILON6 : number

0.000001

static constant Cesium.Math.EPSILON7 : number

0.0000001

static constant Cesium.Math.EPSILON8 : number

0.00000001

static constant Cesium.Math.EPSILON9 : number

0.000000001

static constant Cesium.Math.EPSILON10 : number

0.0000000001

static constant Cesium.Math.EPSILON11 : number

0.00000000001

static constant Cesium.Math.EPSILON12 : number

0.000000000001

static constant Cesium.Math.EPSILON13 : number

0.0000000000001

static constant Cesium.Math.EPSILON14 : number

0.00000000000001

static constant Cesium.Math.EPSILON15 : number

0.000000000000001

static constant Cesium.Math.EPSILON16 : number

0.0000000000000001

static constant Cesium.Math.EPSILON17 : number

0.00000000000000001

static constant Cesium.Math.EPSILON18 : number

0.000000000000000001

static constant Cesium.Math.EPSILON19 : number

0.0000000000000000001

static constant Cesium.Math.EPSILON20 : number

0.00000000000000000001

static constant Cesium.Math.EPSILON21 : number

0.000000000000000000001

static constant Cesium.Math.FOUR_GIGABYTES : number

4 * 1024 * 1024 * 1024

static constant Cesium.Math.GRAVITATIONALPARAMETER : number

以立方米计的地球引力参数 按 NT 0 型号定义的每秒平方: 3.986004418e14

static constant Cesium.Math.LUNAR_RADIUS : number

月球的平均半径,根据" -IAU / -IAG "的报告. 人权委员会 -NT=0=- 翻译: 行星和卫星的坐标和旋转要素:2000年”, Celestial Mechanics 82: 83-110, 2002.

static constant Cesium.Math.ONE_OVER_PI : number

1/pi

static constant Cesium.Math.ONE_OVER_TWO_PI : number

1/2pi

static constant Cesium.Math.PI : number

pi

static constant Cesium.Math.PI_OVER_FOUR : number

pi/4

static constant Cesium.Math.PI_OVER_SIX : number

pi/6

static constant Cesium.Math.PI_OVER_THREE : number

pi/3

static constant Cesium.Math.PI_OVER_TWO : number

pi/2

static constant Cesium.Math.RADIANS_PER_ARCSECOND : number

弧秒的弧度数.

static constant Cesium.Math.RADIANS_PER_DEGREE : number

一个学位的弧度数.

static constant Cesium.Math.SIXTY_FOUR_KILOBYTES : number

64 * 1024

static constant Cesium.Math.SOLAR_RADIUS : number

以米计的太阳半径: 6.955e8

static constant Cesium.Math.THREE_PI_OVER_TWO : number

3pi/2

static constant Cesium.Math.TWO_PI : number

2pi

Methods

static Cesium.Math.acosClamped(value)number

Computes Math.acos(value), but first clamps value to the range [-1.0, 1.0] 这样,函数就永远不会返回NaN.
Name Type Description
value number 计算acos的值.
Returns:
如果值在 [- 1.0, 1.0] 范围内, 或为 - 1.0 或 1.0 的 cos, 则该值的acos , 如果值超出范围,则以更接近者为准.

static Cesium.Math.asinClamped(value)number

Computes Math.asin(value), but first clamps value to the range [-1.0, 1.0] 这样,函数就永远不会返回NaN.
Name Type Description
value number 用于计算的价值.
Returns:
如果值在 [-1.0, 1.0] 或 -1.0 或 1.0 或 1.0 之间,则该值的当量, 如果值超出范围,则以更接近者为准.

static Cesium.Math.cbrt(number)number

查找数字的立方根. Returns NaN if number is not provided.
Name Type Description
number number optional The number.
Returns:
The result.

static Cesium.Math.chordLength(angle, radius)number

根据圆的半径和点间的角,在两点之间找到和弦长度.
Name Type Description
angle number 两点之间的角度.
radius number 圆之半径.
Returns:
弦长.

static Cesium.Math.clamp(value, min, max)number

限制两个值之间的值.
Name Type Description
value number 夹的值.
min number 最低值.
max number 最大值 .
Returns:
被夹住的值如此小 QQ 结果最大 .

static Cesium.Math.clampToLatitudeRange(angle)number

Convenience function that clamps a latitude value, in radians, to the range [-Math.PI/2, Math.PI/2). 可用于在需要正确范围的物体中使用前对数据进行消毒.
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));

static Cesium.Math.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
const longitude = Cesium.Math.convertLongitudeRange(Cesium.Math.toRadians(270.0));

static Cesium.Math.cosh(value)number

返回数字的双曲余弦. # 的双曲余弦被定义为 (ex + e-x)/2.0 其中 NT 0 e NT 1 为欧拉的号码,约为2.7828183. 特殊情况:
  • 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 1.0.

Name Type Description
value number 双曲余弦要返回的号码 .
Returns:
双曲余弦为 NT 0 值 NT 1 .

static Cesium.Math.equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon)boolean

使用绝对或相对容忍度测试确定两个值是否相等。 这个有用 以避免直接比较浮点值时出现圆形错误。 数值是 首先用绝对容忍度测试来比较。 如果失败,将进行相对耐受性测试. 如果您不确定左右大小, 请使用此测试 .
Name Type Default Description
left number 第一个比较值.
right number 另一个值来比较.
relativeEpsilon number 0 optional The maximum inclusive delta between left and right for the relative tolerance test.
absoluteEpsilon number 相对Epsilon optional 绝对耐受性测试在 之间的最大包容性三角.
Returns:
如果值在 epsilon 内为等值,则使用 NT 0 true NT 1 ;否则, NT 2 false NT 3 .
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

static Cesium.Math.factorial(n)number

计算所提供的数字的因数.
Name Type Description
n number 计算因数的号码.
Returns:
如果数字小于 0,则提供的数字或未定义的数字的因数.
Throws:
Example:
//Compute 7!, which is equal to 5040
const computedFactorial = Cesium.Math.factorial(7);
See:

static Cesium.Math.fastApproximateAtan(x)number

计算Atan在范围[-1,1]中输入的快速近似. 根据Michal Drobot从Shader FastLibs的近似, 它又基于“弧度函数的 有效近似值” 拉詹, S. Sichun Wang Inkol, R. Joyal, A., 2006年5月. 由ShaderFastLibs根据 NT 0 执照.
Name Type Description
x number 范围 [-1, 1] 中的输入编号
Returns:
An approximation of atan(x)

static Cesium.Math.fastApproximateAtan2(x, y)number

计算Atan2(x,y)的快速近似值,用于任意输入scalars. 基于 nvidia 的 cg 引用执行的缩小范围数学 : http://developer.download.nvidia.com/cg/atan2.html
Name Type Description
x number 如果 Y 是 0 , 输入数字不是 0 .
y number 如果 x 是 0 , 输入数字不是 0 .
Returns:
An approximation of atan2(x, y)

static Cesium.Math.fromSNorm(value, rangeMaximum)number

将位于[0,范围Maximum]范围内的 NT% 0 值转换为位于[-1.0,1.0]范围内的scalar.
Name Type Default Description
value number SNORM value in the range [0, rangeMaximum]
rangeMaximum number 255 optional 最大值在 NT 0 范围内,默认为255.
Returns:
射程中的斯卡拉[-1.0,1.0].
See:
  • CesiumMath.toSNorm

static Cesium.Math.greaterThan(left, right, absoluteEpsilon)boolean

确定左值是否大于右值。 如果这两个值在其中 absoluteEpsilon of each other, they are considered equal and this function returns false.
Name Type Description
left number 第一个比较的数字.
right number 第二数相比较.
absoluteEpsilon number 用于比较的绝对epsilon.
Returns:
-NT############################################################################################################################################################################################################################################################# 超过 absoluteEpsilon. false if left is less or if the two 价值观几乎是平等的.

static Cesium.Math.greaterThanOrEquals(left, right, absoluteEpsilon)boolean

确定左值是否大于或等于右值。 如果这两个值都在其中 ~~绝对Epsilon −彼此,它们被认为是平等的,此函数返回为真.
Name Type Description
left number 第一个比较的数字.
right number 第二数相比较.
absoluteEpsilon number 用于比较的绝对epsilon.
Returns:
-NT############################################################################################################################################################################################################################################################# 或如果 价值几乎相等.

static Cesium.Math.incrementWrap(n, maximumValue, minimumValue)number

如果数字超过最大值,则将数字加起来,并加到最小值.
Name Type Default Description
n number optional 应加之数.
maximumValue number optional 滚动到最小值前的最大递增值 .
minimumValue number 0.0 optional 数字重置到超过最大值后.
Returns:
递增数.
Throws:
Example:
const n = Cesium.Math.incrementWrap(5, 10, 0); // returns 6
const m = Cesium.Math.incrementWrap(10, 10, 0); // returns 0

static Cesium.Math.isPowerOfTwo(n)boolean

确定非负整数是否为2的功率. 由于Javascript中的32位位位操作者限制,允许输入的最大值为(2^32-1).
Name Type Description
n number 在范围测试的整数 [0], (2^32-1).
Returns:
NT##0 真 NT####1 如果数字为2;否则, NT 2 假 NT 3 .
Throws:
Example:
const t = Cesium.Math.isPowerOfTwo(16); // true
const f = Cesium.Math.isPowerOfTwo(20); // false

static Cesium.Math.lerp(p, q, time)number

计算两个值的线性插值.
Name Type Description
p number 插图的起始值 .
q number 插图的最终值 .
time number 内插时间一般在 NT 0 [0.0,1.0] NT 1 .
Returns:
线性插值.
Example:
const n = Cesium.Math.lerp(0.0, 2.0, 0.5); // returns 1.0

static Cesium.Math.lessThan(left, right, absoluteEpsilon)boolean

确定左值是否小于右值。 如果这两个值在其中 absoluteEpsilon of each other, they are considered equal and this function returns false.
Name Type Description
left number 第一个比较的数字.
right number 第二数相比较.
absoluteEpsilon number 用于比较的绝对epsilon.
Returns:
-NT############################################################################################################################################################################################################################################################# absoluteEpsilon. false if left is greater or if the two 价值观几乎是平等的.

static Cesium.Math.lessThanOrEquals(left, right, absoluteEpsilon)boolean

确定左值小于或等于右值。 如果这两个值都在其中 ~~绝对Epsilon −彼此,它们被认为是平等的,此函数返回为真.
Name Type Description
left number 第一个比较的数字.
right number 第二数相比较.
absoluteEpsilon number 用于比较的绝对epsilon.
Returns:
如果 小于 或如果 价值几乎相等.

static Cesium.Math.log2(number)number

查找数字的基数 2 对数.
Name Type Description
number number The number.
Returns:
The result.

static Cesium.Math.logBase(number, base)number

查找数字到基数的对数.
Name Type Description
number number The number.
base number The base.
Returns:
The result.

static Cesium.Math.mod(m, n)number

也有利于负红利的modulo操作.
Name Type Description
m number The dividend.
n number The divisor.
Returns:
The remainder.

static Cesium.Math.negativePiToPi(angle)number

产生一个角度在范围 - Pi QQ角度 QQ Pi, 相当于所提供的角度 .
Name Type Description
angle number in radians
Returns:
The angle in the range [-CesiumMath.PI, CesiumMath.PI].

static Cesium.Math.nextPowerOfTwo(n)number

计算2个整数中的下一个功率大于或等于所提供的非负整数. 由于Javascript中32位位比特操作者的限制,允许输入的最大值为2^31.
Name Type Description
n number The integer to test in the range [0, 2^31].
Returns:
下一部二力整数.
Throws:
Example:
const n = Cesium.Math.nextPowerOfTwo(29); // 32
const m = Cesium.Math.nextPowerOfTwo(32); // 32

static Cesium.Math.nextRandomNumber()number

Generates a random floating point number in the range of [0.0, 1.0) 使用梅森纳扭矩.
Returns:
A random number in the range of [0.0, 1.0).
See:

static Cesium.Math.normalize(value, rangeMinimum, rangeMaximum)number

将范围 [最小范围,最大范围] 的刻度值转换为范围 [0.0, 1.0] 的刻度值
Name Type Description
value number 范围中的 scalar 值 [范围最小值, 范围最大值]
rangeMinimum number 绘图范围内最小值 .
rangeMaximum number 绘图范围内的最大值 .
Returns:
一个scalar值,其中最小地图范围为0.0,最小地图范围为1.0.

static Cesium.Math.previousPowerOfTwo(n)number

计算先前的2个整数的功率小于或等于所提供的非负整数. 由于Javascript中的32位位位操作者限制,允许输入的最大值为(2^32-1).
Name Type Description
n number 在范围测试的整数 [0], (2^32-1).
Returns:
之前的二强整数.
Throws:
Example:
const n = Cesium.Math.previousPowerOfTwo(29); // 16
const m = Cesium.Math.previousPowerOfTwo(32); // 32

static Cesium.Math.randomBetween(min, max)number

生成两个数字之间的随机数字.
Name Type Description
min number 最低值.
max number 最大值 .
Returns:
分钟和最大值之间的随机数字 .

static Cesium.Math.setRandomNumberSeed(seed)

设置随机数生成器所用的种子 in CesiumMath#nextRandomNumber.
Name Type Description
seed number 用作种子的整数.

static Cesium.Math.sign(value)number

返回值的标志; 1 如果值为正值, - 1 如果值为 负值,如果值为 0,则为 0.
Name Type Description
value number 值以还兆.
Returns:
价值之迹.

static Cesium.Math.signNotZero(value)number

如果给定值为正值或零,返回1.0,如果为负值,返回-1.0. This is similar to CesiumMath#sign except that returns 1.0 instead of 0.0 当输入值为 0.0.
Name Type Description
value number 值以还兆.
Returns:
价值之迹.

static Cesium.Math.sinh(value)number

返回数字的双曲正弦 . #NT##0 值 NT###1 的双曲正弦被定义为 (ex - e-x)/2.0 其中 NT 0 e NT 1 为欧拉的号码,约为2.7828183. 特殊情况:
  • 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 与 NT 1 同号

Name Type Description
value number 返回双曲正弦的号码 .
Returns:
双曲正弦为 .

static Cesium.Math.toDegrees(radians)number

将弧度转换为度 .
Name Type Description
radians number 用弧度转换的角度.
Returns:
相应的角度以度表示.

static Cesium.Math.toRadians(degrees)number

将学位转换为弧度.
Name Type Description
degrees number 以度表示的转换角度 .
Returns:
相应的弧度角.

static Cesium.Math.toSNorm(value, rangeMaximum)number

将范围 [-1.0, 1.0] 的刻度值转换为范围 [0, 范围 Maximum] 的 SNORM
Name Type Default Description
value number 范围中的 scalar 值 [- 1.0, 1.0]
rangeMaximum number 255 optional 地图范围内的最大值,默认为255.
Returns:
一个 NT 0 值,其中 0 地图为 -1.0, 范围为 Maximum 地图为 1.0.
See:
  • CesiumMath.fromSNorm

static Cesium.Math.zeroToTwoPi(angle)number

产生0 QQ 角度 QQ 2Pi 的角,相当于所提供的角 .
Name Type Description
angle number in radians
Returns:
The angle in the range [0, CesiumMath.TWO_PI].
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.