Appearance
KBE3D / KBCore / Cesium / Math / equalsEpsilon
函数: equalsEpsilon()
equalsEpsilon(
left:number,right:number,relativeEpsilon?:number,absoluteEpsilon?:number):boolean
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.
参数
left
number
The first value to compare.
right
number
The other value to compare.
relativeEpsilon?
number
The maximum inclusive delta between <code>left</code> and <code>right</code> for the relative tolerance test.
absoluteEpsilon?
number
The maximum inclusive delta between <code>left</code> and <code>right</code> for the absolute tolerance test.
返回
boolean
true if the values are equal within the epsilon; otherwise, false.
示例
ts
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