diff --git a/Source/Core/OrthographicFrustum.js b/Source/Core/OrthographicFrustum.js
index b2dd5ef7e074..c155db23bfbc 100644
--- a/Source/Core/OrthographicFrustum.js
+++ b/Source/Core/OrthographicFrustum.js
@@ -4,6 +4,7 @@ define([
'./defined',
'./defineProperties',
'./DeveloperError',
+ './Math',
'./OrthographicOffCenterFrustum'
], function(
Check,
@@ -11,6 +12,7 @@ define([
defined,
defineProperties,
DeveloperError,
+ CesiumMath,
OrthographicOffCenterFrustum) {
'use strict';
@@ -273,5 +275,30 @@ define([
this._offCenterFrustum.equals(other._offCenterFrustum));
};
+ /**
+ * Compares the provided OrthographicFrustum componentwise and returns
+ * true
if they pass an absolute or relative tolerance test,
+ * false
otherwise.
+ *
+ * @param {OrthographicFrustum} [other] The right hand side OrthographicFrustum.
+ * @param {Number} relativeEpsilon The relative epsilon tolerance to use for equality testing.
+ * @param {Number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
+ * @returns {Boolean} true
if this and other are within the provided epsilon, false
otherwise.
+ */
+ OrthographicFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
+ if (!defined(other) || !(other instanceof OrthographicFrustum)) {
+ return false;
+ }
+
+ update(this);
+ update(other);
+
+ return (CesiumMath.equalsEpsilon(this.width, other.width, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.aspectRatio, other.aspectRatio, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.near, other.near, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.far, other.far, relativeEpsilon, absoluteEpsilon) &&
+ this._offCenterFrustum.equalsEpsilon(other._offCenterFrustum, relativeEpsilon, absoluteEpsilon));
+ };
+
return OrthographicFrustum;
});
diff --git a/Source/Core/OrthographicOffCenterFrustum.js b/Source/Core/OrthographicOffCenterFrustum.js
index 09877fba03b2..3e3ff8f8a6dc 100644
--- a/Source/Core/OrthographicOffCenterFrustum.js
+++ b/Source/Core/OrthographicOffCenterFrustum.js
@@ -6,6 +6,7 @@ define([
'./defined',
'./defineProperties',
'./DeveloperError',
+ './Math',
'./Matrix4'
], function(
Cartesian3,
@@ -15,6 +16,7 @@ define([
defined,
defineProperties,
DeveloperError,
+ CesiumMath,
Matrix4) {
'use strict';
@@ -370,5 +372,27 @@ define([
this.far === other.far);
};
+ /**
+ * Compares the provided OrthographicOffCenterFrustum componentwise and returns
+ * true
if they pass an absolute or relative tolerance test,
+ * false
otherwise.
+ *
+ * @param {OrthographicOffCenterFrustum} [other] The right hand side OrthographicOffCenterFrustum.
+ * @param {Number} relativeEpsilon The relative epsilon tolerance to use for equality testing.
+ * @param {Number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
+ * @returns {Boolean} true
if this and other are within the provided epsilon, false
otherwise.
+ */
+ OrthographicOffCenterFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
+ return (other === this) ||
+ (defined(other) &&
+ other instanceof OrthographicOffCenterFrustum &&
+ CesiumMath.equalsEpsilon(this.right, other.right, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.left, other.left, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.top, other.top, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.bottom, other.bottom, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.near, other.near, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.far, other.far, relativeEpsilon, absoluteEpsilon));
+ };
+
return OrthographicOffCenterFrustum;
});
diff --git a/Source/Core/PerspectiveFrustum.js b/Source/Core/PerspectiveFrustum.js
index 3186170bbd77..719677c8ca81 100644
--- a/Source/Core/PerspectiveFrustum.js
+++ b/Source/Core/PerspectiveFrustum.js
@@ -4,6 +4,7 @@ define([
'./defined',
'./defineProperties',
'./DeveloperError',
+ './Math',
'./PerspectiveOffCenterFrustum'
], function(
Check,
@@ -11,6 +12,7 @@ define([
defined,
defineProperties,
DeveloperError,
+ CesiumMath,
PerspectiveOffCenterFrustum) {
'use strict';
@@ -368,5 +370,30 @@ define([
this._offCenterFrustum.equals(other._offCenterFrustum));
};
+ /**
+ * Compares the provided PerspectiveFrustum componentwise and returns
+ * true
if they pass an absolute or relative tolerance test,
+ * false
otherwise.
+ *
+ * @param {PerspectiveFrustum} [other] The right hand side PerspectiveFrustum.
+ * @param {Number} relativeEpsilon The relative epsilon tolerance to use for equality testing.
+ * @param {Number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
+ * @returns {Boolean} true
if this and other are within the provided epsilon, false
otherwise.
+ */
+ PerspectiveFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
+ if (!defined(other) || !(other instanceof PerspectiveFrustum)) {
+ return false;
+ }
+
+ update(this);
+ update(other);
+
+ return (CesiumMath.equalsEpsilon(this.fov, other.fov, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.aspectRatio, other.aspectRatio, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.near, other.near, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.far, other.far, relativeEpsilon, absoluteEpsilon) &&
+ this._offCenterFrustum.equalsEpsilon(other._offCenterFrustum, relativeEpsilon, absoluteEpsilon));
+ };
+
return PerspectiveFrustum;
});
diff --git a/Source/Core/PerspectiveOffCenterFrustum.js b/Source/Core/PerspectiveOffCenterFrustum.js
index 30319a5b2556..2e8fad7f0aca 100644
--- a/Source/Core/PerspectiveOffCenterFrustum.js
+++ b/Source/Core/PerspectiveOffCenterFrustum.js
@@ -6,6 +6,7 @@ define([
'./defined',
'./defineProperties',
'./DeveloperError',
+ './Math',
'./Matrix4'
], function(
Cartesian3,
@@ -15,6 +16,7 @@ define([
defined,
defineProperties,
DeveloperError,
+ CesiumMath,
Matrix4) {
'use strict';
@@ -421,5 +423,27 @@ define([
this.far === other.far);
};
+ /**
+ * Compares the provided PerspectiveOffCenterFrustum componentwise and returns
+ * true
if they pass an absolute or relative tolerance test,
+ * false
otherwise.
+ *
+ * @param {PerspectiveOffCenterFrustum} [other] The right hand side PerspectiveOffCenterFrustum.
+ * @param {Number} relativeEpsilon The relative epsilon tolerance to use for equality testing.
+ * @param {Number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
+ * @returns {Boolean} true
if this and other are within the provided epsilon, false
otherwise.
+ */
+ PerspectiveOffCenterFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
+ return (other === this) ||
+ (defined(other) &&
+ other instanceof PerspectiveOffCenterFrustum &&
+ CesiumMath.equalsEpsilon(this.right, other.right, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.left, other.left, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.top, other.top, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.bottom, other.bottom, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.near, other.near, relativeEpsilon, absoluteEpsilon) &&
+ CesiumMath.equalsEpsilon(this.far, other.far, relativeEpsilon, absoluteEpsilon));
+ };
+
return PerspectiveOffCenterFrustum;
});
diff --git a/Specs/Core/OrthographicFrustumSpec.js b/Specs/Core/OrthographicFrustumSpec.js
index 4ac99bd4e0ec..19128d920b8f 100644
--- a/Specs/Core/OrthographicFrustumSpec.js
+++ b/Specs/Core/OrthographicFrustumSpec.js
@@ -175,6 +175,42 @@ defineSuite([
expect(pixelSize.y).toEqual(2.0);
});
+ it('equals', function() {
+ var frustum2 = new OrthographicFrustum();
+ frustum2.near = 1.0;
+ frustum2.far = 3.0;
+ frustum2.width = 2.0;
+ frustum2.aspectRatio = 1.0;
+ expect(frustum.equals(frustum2)).toEqual(true);
+ });
+
+ it('equals epsilon', function() {
+ var frustum2 = new OrthographicFrustum();
+ frustum2.near = 1.0;
+ frustum2.far = 3.0;
+ frustum2.width = 2.0;
+ frustum2.aspectRatio = 1.0;
+ expect(frustum.equalsEpsilon(frustum2, CesiumMath.EPSILON7)).toEqual(true);
+
+ var frustum3 = new OrthographicFrustum();
+ frustum3.near = 1.01;
+ frustum3.far = 3.01;
+ frustum3.width = 2.01;
+ frustum3.aspectRatio = 1.01;
+ expect(frustum.equalsEpsilon(frustum3, CesiumMath.EPSILON1)).toEqual(true);
+
+ var frustum4 = new OrthographicFrustum();
+ frustum4.near = 1.0;
+ frustum4.far = 3.0;
+ frustum4.width = 2.0;
+ frustum4.aspectRatio = 1.1;
+ expect(frustum.equalsEpsilon(frustum4, CesiumMath.EPSILON2)).toEqual(false);
+ });
+
+ fit('equals undefined', function() {
+ expect(frustum.equals()).toEqual(false);
+ });
+
it('throws with undefined frustum parameters', function() {
var frustum = new OrthographicFrustum();
expect(function() {
diff --git a/Specs/Core/OrthographicOffCenterFrustumSpec.js b/Specs/Core/OrthographicOffCenterFrustumSpec.js
index a81c88f087dc..856ac0dcc121 100644
--- a/Specs/Core/OrthographicOffCenterFrustumSpec.js
+++ b/Specs/Core/OrthographicOffCenterFrustumSpec.js
@@ -176,6 +176,51 @@ defineSuite([
expect(pixelSize.y).toEqual(2.0);
});
+ it('equals', function() {
+ var frustum2 = new OrthographicOffCenterFrustum();
+ frustum2.near = 1.0;
+ frustum2.far = 3.0;
+ frustum2.right = 1.0;
+ frustum2.left = -1.0;
+ frustum2.top = 1.0;
+ frustum2.bottom = -1.0;
+
+ expect(frustum).toEqual(frustum2);
+ });
+
+ it('equals epsilon', function() {
+ var frustum2 = new OrthographicOffCenterFrustum();
+ frustum2.near = 1.0;
+ frustum2.far = 3.0;
+ frustum2.right = 1.0;
+ frustum2.left = -1.0;
+ frustum2.top = 1.0;
+ frustum2.bottom = -1.0;
+ expect(frustum.equalsEpsilon(frustum2, CesiumMath.EPSILON7)).toEqual(true);
+
+ var frustum3 = new OrthographicOffCenterFrustum();
+ frustum3.near = 1.01;
+ frustum3.far = 2.98;
+ frustum3.right = 1.02;
+ frustum3.left = -0.99;
+ frustum3.top = 0.99;
+ frustum3.bottom = -1.05;
+ expect(frustum.equalsEpsilon(frustum3, CesiumMath.EPSILON1)).toEqual(true);
+
+ var frustum4 = new OrthographicOffCenterFrustum();
+ frustum4.near = 1.1;
+ frustum4.far = 2.9;
+ frustum4.right = 0.0;
+ frustum4.left = -1.02;
+ frustum4.top = 1.02;
+ frustum4.bottom = -1.005;
+ expect(frustum.equalsEpsilon(frustum4, CesiumMath.EPSILON2)).toEqual(false);
+ });
+
+ it('equals undefined', function() {
+ expect(frustum.equals()).toEqual(false);
+ });
+
it('throws with undefined frustum parameters', function() {
var frustum = new OrthographicOffCenterFrustum();
expect(function() {
diff --git a/Specs/Core/PerspectiveFrustumSpec.js b/Specs/Core/PerspectiveFrustumSpec.js
index 7682b09d6ffc..4ec7d5a17f64 100644
--- a/Specs/Core/PerspectiveFrustumSpec.js
+++ b/Specs/Core/PerspectiveFrustumSpec.js
@@ -180,6 +180,29 @@ defineSuite([
expect(frustum.equals(frustum2)).toEqual(true);
});
+ it('equals epsilon', function() {
+ var frustum2 = new PerspectiveFrustum();
+ frustum2.near = 1.0;
+ frustum2.far = 2.0;
+ frustum2.fov = (Math.PI) / 3.0;
+ frustum2.aspectRatio = 1.0;
+ expect(frustum.equalsEpsilon(frustum2, CesiumMath.EPSILON7)).toEqual(true);
+
+ var frustum3 = new PerspectiveFrustum();
+ frustum3.near = 1.01;
+ frustum3.far = 2.01;
+ frustum3.fov = ((Math.PI) / 3.0) + 0.01;
+ frustum3.aspectRatio = 1.01;
+ expect(frustum.equalsEpsilon(frustum3, CesiumMath.EPSILON1)).toEqual(true);
+
+ var frustum4 = new PerspectiveFrustum();
+ frustum4.near = 1.0;
+ frustum4.far = 2.0;
+ frustum4.fov = (Math.PI) / 3.0;
+ frustum4.aspectRatio = 1.1;
+ expect(frustum.equalsEpsilon(frustum4, CesiumMath.EPSILON2)).toEqual(false);
+ });
+
it('equals undefined', function() {
expect(frustum.equals()).toEqual(false);
});
diff --git a/Specs/Core/PerspectiveOffCenterFrustumSpec.js b/Specs/Core/PerspectiveOffCenterFrustumSpec.js
index 937f0d2a499f..39d49da802c7 100644
--- a/Specs/Core/PerspectiveOffCenterFrustumSpec.js
+++ b/Specs/Core/PerspectiveOffCenterFrustumSpec.js
@@ -195,6 +195,39 @@ defineSuite([
expect(frustum).toEqual(frustum2);
});
+ it('equals epsilon', function() {
+ var frustum2 = new PerspectiveOffCenterFrustum();
+ frustum2.right = 1.0;
+ frustum2.left = -frustum.right;
+ frustum2.top = 1.0;
+ frustum2.bottom = -frustum.top;
+ frustum2.near = 1.0;
+ frustum2.far = 2.0;
+ expect(frustum.equalsEpsilon(frustum2, CesiumMath.EPSILON7)).toEqual(true);
+
+ var frustum3 = new PerspectiveOffCenterFrustum();
+ frustum3.right = 1.01;
+ frustum3.left = -frustum.right;
+ frustum3.top = 1.01;
+ frustum3.bottom = -frustum.top;
+ frustum3.near = 1.01;
+ frustum3.far = 1.99;
+ expect(frustum.equalsEpsilon(frustum3, CesiumMath.EPSILON1)).toEqual(true);
+
+ var frustum4 = new PerspectiveOffCenterFrustum();
+ frustum4.right = 1.1;
+ frustum4.left = -frustum.right;
+ frustum4.top = 1.0;
+ frustum4.bottom = -frustum.top;
+ frustum4.near = 1.0;
+ frustum4.far = 2.0;
+ expect(frustum.equalsEpsilon(frustum4, CesiumMath.EPSILON2)).toEqual(false);
+ });
+
+ it('equals undefined', function() {
+ expect(frustum.equals()).toEqual(false);
+ });
+
it('throws with undefined frustum parameters', function() {
var frustum = new PerspectiveOffCenterFrustum();
expect(function() {