Math

数学函数。

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

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

以米为单位的地球引力参数 WGS84型号定义的每秒平方:3.986004418e14

static constant Cesium.Math.LUNAR_RADIUS : Number

月球的平均半径 地图坐标和行星和卫星的旋转元素:2000年“, 天体力学82:83-1102002。

static constant Cesium.Math.ONE_OVER_PI : Number

1/π

static constant Cesium.Math.ONE_OVER_TWO_PI : Number

1/2磅

static constant Cesium.Math.PI : Number

圆周率

static constant Cesium.Math.PI_OVER_FOUR : Number

圆周率/4

static constant Cesium.Math.PI_OVER_SIX : Number

圆周率/6

static constant Cesium.Math.PI_OVER_THREE : Number

圆周率/3

static constant Cesium.Math.PI_OVER_TWO : Number

π/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

3便士/2

static constant Cesium.Math.TWO_PI : Number

2磅

Methods

static Cesium.Math.acosClamped(value)Number

计算Math.acos(value),但首先将value钳制到范围[-1.0,1.0] 所以函数永远不会返回NaN。
Name Type Description
value Number 计算ACO的值。
Returns:
如果值在[-1.0,1.0]或-1.0或1.0的ACO范围内,则值的ACO, 如果值超出范围,则以较近者为准。

static Cesium.Math.asinClamped(value)Number

计算Math.asin(value),但首先将value钳制到范围[-1.0,1.0] 所以函数永远不会返回NaN。
Name Type Description
value Number 要计算asin的值。
Returns:
如果值在范围[-1.0,1.0]内,则为该值的asin,或-1.0或1.0的asin, 如果值超出范围,则以较接近的为准。

static Cesium.Math.cbrt(number)Number

找到number的立方根。 如果未提供数字,则返回NaN。
Name Type Description
number Number optional 号码。
Returns:
结果。

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:
钳制值,使最小值<=值<=最大值。

static Cesium.Math.clampToLatitudeRange(angle)Number

方便函数,它将纬度值(以弧度为单位)固定到范围[-Math.PI/2Math.PI/2)。 用于在需要正确范围的对象中使用之前对数据进行清理。
Name Type Description
angle Number 要钳制到范围[-Math.PI/2Math.PI/2)的纬度值(以弧度为单位)。
Returns:
纬度值固定在范围[-Math.PI/2Math.PI/2)。
Example:
// Clamp 108 degrees latitude to 90 degrees latitude
var latitude = Cesium.Math.clampToLatitudeRange(Cesium.Math.toRadians(108.0));

static Cesium.Math.convertLongitudeRange(angle)Number

将以弧度为单位的经度值转换为范围[-Math.PIMath.PI)。
Name Type Description
angle Number 要转换为范围[-Math.PIMath.PI)的经度值(以弧度为单位)。
Returns:
范围[-Math.PIMath.PI)中的等效经度值。
Example:
// Convert 270 degrees to -90 degrees longitude
var longitude = Cesium.Math.convertLongitudeRange(Cesium.Math.toRadians(270.0));

static Cesium.Math.cosh(value)Number

re转换一个数字的双曲余弦。 双曲余弦value定义为 (ex + e-x)/2.0 其中e是欧拉数,约为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 1.0.
Name Type Description
value Number 要返回其双曲余弦的数字。
Returns:
双曲余弦为value

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

使用绝对或相对公差测试确定两个值是否相等。这很有用 以避免在直接比较浮点值时由于舍入误差而产生的问题。价值观是 首先用绝对公差试验进行比较。如果失败,则进行相对公差测试。 如果您不确定左右的大小,请使用此测试。
Name Type Default Description
left Number 要比较的第一个值。
right Number 要比较的另一个值。
relativeEpsilon Number 0 optional 相对公差试验leftright之间的最大包含增量。
absoluteEpsilon Number relativeEpsilon optional 绝对公差试验leftright之间的最大包含增量。
Returns:
如果值在epsilon内相等,则为true;否则为false
Example:
var a = Cesium.Math.equalsEpsilon(0.0, 0.01, Cesium.Math.EPSILON2); // true
var b = Cesium.Math.equalsEpsilon(0.0, 0.1, Cesium.Math.EPSILON2);  // false
var c = Cesium.Math.equalsEpsilon(3699175.1634344, 3699175.2, Cesium.Math.EPSILON7); // true
var 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
var computedFactorial = Cesium.Math.factorial(7);
See:

static Cesium.Math.fastApproximateAtan(x)Number

计算输入在[-1,1]范围内的Atan的快速近似值。 基于Michal Drobot从ShaderFastLibs得到的近似值, 这又是基于“反正切函数的有效近似” Rajan,S.Sichun Wang Inkol,R.Joyal,A.,2006年5月。 改编自麻省理工学院授权的ShaderFastLibs。
Name Type Description
x Number 范围为[-1,1]的输入数字
Returns:
atan(x)的一个近似

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

计算任意输入标量的Atan2(x,y)的快速近似值。 基于nvidia cg参考实现的距离缩小数学:http://developer.download.nvidia.com/cg/atan2.html
Name Type Description
x Number 如果y为零则不为零的输入数。
y Number 如果x为零,则为非零的输入数。
Returns:
atan2(x,y)的近似值

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

将范围[0,rangeMaximum]内的SNORM值转换为范围[-1.0,1.0]的标量。
Name Type Default Description
value Number 范围[0,rangeMaximum]内的SNORM值
rangeMaximum Number 255 optional snom范围内的最大值,默认为255。
Returns:
范围为[-1.0,1.0]的标量。
See:
  • CesiumMath.toSNorm

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

确定左值是否大于右值。如果这两个值在 它们被视为相等,此函数返回false。
Name Type Description
left Number 要比较的第一个数字。
right Number 要比较的第二个数字。
absoluteEpsilon Number 用于比较的绝对epsilon。
Returns:
true如果left大于right absoluteEpsilon. false if left is less or if the two values are nearly equal.

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

确定左值是否大于或等于右值。如果两个值在 absoluteEpsilon彼此,它们被认为是相等的,并且该函数返回true。
Name Type Description
left Number 要比较的第一个数字。
right Number 要比较的第二个数字。
absoluteEpsilon Number 用于比较的绝对epsilon。
Returns:
如果left大于right或 这些值几乎相等。

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:
var n = Cesium.Math.incrementWrap(5, 10, 0); // returns 6
var n = Cesium.Math.incrementWrap(10, 10, 0); // returns 0

static Cesium.Math.isPowerOfTwo(n)Boolean

确定正整数是否为2的幂。
Name Type Description
n Number 要测试的正整数。
Returns:
如果数字是2的幂,则为true;否则为false
Throws:
Example:
var t = Cesium.Math.isPowerOfTwo(16); // true
var f = Cesium.Math.isPowerOfTwo(20); // false

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

两个线性插值计算两个值。
Name Type Description
p Number 要插值的起始值。
q Number 要插值的结束值。
time Number 插值时间一般在[0.0, 1.0]范围内。
Returns:
线性插值值。
Example:
var n = Cesium.Math.lerp(0.0, 2.0, 0.5); // returns 1.0

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

确定左值是否小于右值。如果这两个值在 它们被视为相等,此函数返回false。
Name Type Description
left Number 要比较的第一个数字。
right Number 要比较的第二个数字。
absoluteEpsilon Number 用于比较的绝对epsilon。
Returns:
如果left小于right大于616668167,则为true absoluteEpsilon. false if left is greater or if the two values are nearly equal.

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

确定左值是否小于或等于右值。如果这两个值在 它们被视为相等,此函数返回true。
Name Type Description
left Number 要比较的第一个数字。
right Number 要比较的第二个数字。
absoluteEpsilon Number 用于比较的绝对epsilon。
Returns:
如果left小于right或 这些值几乎相等。

static Cesium.Math.log2(number)Number

求一个数以2为底的对数。
Name Type Description
number Number 号码。
Returns:
结果。

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

查找数字对基的对数。
Name Type Description
number Number 号码。
base Number 基地。
Returns:
结果。

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

也适用于负红利的模运算。
Name Type Description
m Number 股息。
n Number 除数。
Returns:
剩下的。

static Cesium.Math.negativePiToPi(angle)Number

生成范围为-Pi<=angle<=Pi的角度,该角度与提供的角度相等。
Name Type Description
angle Number 以弧度表示
Returns:
范围内的角度[-CesiumMath.PICesiumMath.PI]。

static Cesium.Math.nextPowerOfTwo(n)Number

计算大于或等于所提供正整数的两个整数的下一次幂。
Name Type Description
n Number 要测试的正整数。
Returns:
两个整数的下一次幂。
Throws:
Example:
var n = Cesium.Math.nextPowerOfTwo(29); // 32
var m = Cesium.Math.nextPowerOfTwo(32); // 32

static Cesium.Math.nextRandomNumber()Number

生成范围为[0.0,1.0)的随机浮点数 用梅森捻线器。
Returns:
在[0.0,1.0)范围内的随机数。
See:

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

将范围[rangeMinimum,rangeMaximum]中的标量值转换为范围[0.0,1.0]中的标量值
Name Type Description
value Number 范围[rangeMinimum,rangeMaximum]中的标量值
rangeMinimum Number 映射范围中的最小值。
rangeMaximum Number 映射范围中的最大值。
Returns:
标量值,其中rangeMinimum映射为0.0,rangeMaximum映射为1.0。

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

在两个数字之间生成一个随机数。
Name Type Description
min Number 最小值。
max Number 最大值。
Returns:
最小值和最大值之间的随机数。

static Cesium.Math.setRandomNumberSeed(seed)

设置随机数生成器使用的种子 在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。 这与CesiumMath#sign类似,只是返回1.0而不是 输入值为0.0时为0.0。
Name Type Description
value Number 返回符号的值。
Returns:
价值的象征。

static Cesium.Math.sinh(value)Number

re旋转数字的双曲正弦。 value的双曲正弦定义为 (ex - e-x)/2.0 其中e是欧拉数,约为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 要返回其双曲正弦值的数字。
Returns:
value的双曲正弦。

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,rangeMaximum]的SNORM
Name Type Default Description
value Number 范围[-1.0,1.0]中的标量值
rangeMaximum Number 255 optional 映射范围中的最大值,默认为255。
Returns:
一个SNORM值,其中0映射到-1.0,rangeMaximum映射到1.0。
See:
  • CesiumMath.fromSNorm

static Cesium.Math.zeroToTwoPi(angle)Number

生成范围为0<=angle<=2Pi的角度,该角度与提供的角度相等。
Name Type Description
angle Number 以弧度表示
Returns:
在[0CesiumMath.TWO_PI]范围内的角度。