From 8c4ac5d5ca406b4bb0321fe5c2a271372de8836d Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Wed, 12 Apr 2017 09:06:42 -0400 Subject: [PATCH 1/4] fixing rotation mat3 from euler bug --- Source/Core/Matrix3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Matrix3.js b/Source/Core/Matrix3.js index 9cbf90c63002..21bb14a5483c 100644 --- a/Source/Core/Matrix3.js +++ b/Source/Core/Matrix3.js @@ -318,7 +318,7 @@ define([ var m10 = cosTheta * sinPsi; var m11 = cosPhi * cosPsi + sinPhi * sinTheta * sinPsi; - var m12 = -sinTheta * cosPhi + cosPhi * sinTheta * sinPsi; + var m12 = -sinPhi * cosPsi + cosPhi * sinTheta * sinPsi; var m20 = -sinTheta; var m21 = sinPhi * cosTheta; From 2524505b45df7faed8fb55cc2ce7913cc6f69a77 Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Wed, 19 Apr 2017 11:07:33 -0400 Subject: [PATCH 2/4] adding fromHeadingPitchRoll test --- CHANGES.md | 1 + Specs/Core/Matrix3Spec.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 50ada32e0248..e40b4f51ffd4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ Change Log * Added `disableDepthTestDistance` to billboards, points and labels. This sets the distance to the camera where the depth test will be disabled. Setting it to zero (the default) will alwasy enable the depth test. Setting it to `Number.POSITVE_INFINITY` will never enabled the depth test. Also added `scene.minimumDisableDepthTestDistance` to change the default value from zero. [#5166](https://github.com/AnalyticalGraphicsInc/cesium/pull/5166) * Fixed issue with displaying `MapboxImageryProvider` default token error message [#5191](https://github.com/AnalyticalGraphicsInc/cesium/pull/5191) +* Fixed bug in conversion formula in Matrix3.fromHeadingPitchRoll [5195](https://github.com/AnalyticalGraphicsInc/cesium/issues/5195) ### 1.32 - 2017-04-03 diff --git a/Specs/Core/Matrix3Spec.js b/Specs/Core/Matrix3Spec.js index df3c4c009bc3..2170a900999a 100644 --- a/Specs/Core/Matrix3Spec.js +++ b/Specs/Core/Matrix3Spec.js @@ -148,6 +148,24 @@ defineSuite([ expect(returnedResult).toEqualEpsilon(expected, CesiumMath.EPSILON15); }); + it('fromHeadingPitchRoll computed correctly', function() { + var sPi = Math.sin(CesiumMath.PI); + var cPi = Math.cos(CesiumMath.PI); + var sPiOver2 = Math.sin(CesiumMath.PI_OVER_TWO); + var cPiOver2 = Math.cos(CesiumMath.PI_OVER_TWO); + var s3PiOver2 = Math.sin(CesiumMath.PI_OVER_TWO * 3); + var c3PiOver2 = Math.cos(CesiumMath.PI_OVER_TWO * 3); + + var headingPitchRoll = new HeadingPitchRoll(-CesiumMath.PI_OVER_TWO, -CesiumMath.PI, CesiumMath.PI_OVER_TWO * 3); + var expected = new Matrix3(cPi * cPiOver2, -c3PiOver2 * sPiOver2 + s3PiOver2 * sPi * cPiOver2, s3PiOver2 * sPiOver2 + c3PiOver2 * sPi * cPiOver2, + cPi * sPiOver2, c3PiOver2 * cPiOver2 + s3PiOver2 * sPi * sPiOver2, -s3PiOver2 * cPiOver2 + c3PiOver2 * sPi * sPiOver2, + -sPi, s3PiOver2 * cPi, c3PiOver2 * cPi); + var result = new Matrix3(); + var returnedResult = Matrix3.fromHeadingPitchRoll(headingPitchRoll, result); + expect(result).toBe(returnedResult); + expect(returnedResult).toEqualEpsilon(expected, CesiumMath.EPSILON15); + }); + it('fromScale works without a result parameter', function() { var expected = new Matrix3( 7.0, 0.0, 0.0, From f49f5fd69492f258a15ebd8d641933eda012ee4f Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Wed, 19 Apr 2017 12:07:42 -0400 Subject: [PATCH 3/4] changing test --- Specs/Core/Matrix3Spec.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Specs/Core/Matrix3Spec.js b/Specs/Core/Matrix3Spec.js index 2170a900999a..9569c399c3d9 100644 --- a/Specs/Core/Matrix3Spec.js +++ b/Specs/Core/Matrix3Spec.js @@ -149,17 +149,8 @@ defineSuite([ }); it('fromHeadingPitchRoll computed correctly', function() { - var sPi = Math.sin(CesiumMath.PI); - var cPi = Math.cos(CesiumMath.PI); - var sPiOver2 = Math.sin(CesiumMath.PI_OVER_TWO); - var cPiOver2 = Math.cos(CesiumMath.PI_OVER_TWO); - var s3PiOver2 = Math.sin(CesiumMath.PI_OVER_TWO * 3); - var c3PiOver2 = Math.cos(CesiumMath.PI_OVER_TWO * 3); - var headingPitchRoll = new HeadingPitchRoll(-CesiumMath.PI_OVER_TWO, -CesiumMath.PI, CesiumMath.PI_OVER_TWO * 3); - var expected = new Matrix3(cPi * cPiOver2, -c3PiOver2 * sPiOver2 + s3PiOver2 * sPi * cPiOver2, s3PiOver2 * sPiOver2 + c3PiOver2 * sPi * cPiOver2, - cPi * sPiOver2, c3PiOver2 * cPiOver2 + s3PiOver2 * sPi * sPiOver2, -s3PiOver2 * cPiOver2 + c3PiOver2 * sPi * sPiOver2, - -sPi, s3PiOver2 * cPi, c3PiOver2 * cPi); + var expected = Matrix3.fromQuaternion(Quaternion.fromHeadingPitchRoll(headingPitchRoll)); var result = new Matrix3(); var returnedResult = Matrix3.fromHeadingPitchRoll(headingPitchRoll, result); expect(result).toBe(returnedResult); From d9e64c824eb287efa3aa9f43634890eccd506fe4 Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Thu, 20 Apr 2017 15:31:01 -0400 Subject: [PATCH 4/4] updating test with hard coded vals --- Specs/Core/Matrix3Spec.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Specs/Core/Matrix3Spec.js b/Specs/Core/Matrix3Spec.js index 9569c399c3d9..f00b85ae612d 100644 --- a/Specs/Core/Matrix3Spec.js +++ b/Specs/Core/Matrix3Spec.js @@ -149,14 +149,20 @@ defineSuite([ }); it('fromHeadingPitchRoll computed correctly', function() { - var headingPitchRoll = new HeadingPitchRoll(-CesiumMath.PI_OVER_TWO, -CesiumMath.PI, CesiumMath.PI_OVER_TWO * 3); - var expected = Matrix3.fromQuaternion(Quaternion.fromHeadingPitchRoll(headingPitchRoll)); + // Expected generated via STK Components + var expected = new Matrix3( + 0.754406506735489, 0.418940943945763, 0.505330889696038, + 0.133022221559489, 0.656295369162553, -0.742685314912828, + -0.642787609686539, 0.627506871597133, 0.439385041770705); + + var headingPitchRoll = new HeadingPitchRoll(-CesiumMath.toRadians(10), -CesiumMath.toRadians(40), CesiumMath.toRadians(55)); var result = new Matrix3(); var returnedResult = Matrix3.fromHeadingPitchRoll(headingPitchRoll, result); expect(result).toBe(returnedResult); expect(returnedResult).toEqualEpsilon(expected, CesiumMath.EPSILON15); }); + it('fromScale works without a result parameter', function() { var expected = new Matrix3( 7.0, 0.0, 0.0,