Skip to content

Commit

Permalink
Revert "Merge pull request #5872 from AnalyticalGraphicsInc/revert"
Browse files Browse the repository at this point in the history
This reverts commit 0ccd97c, reversing
changes made to 9b05ee6.
  • Loading branch information
bagnell committed Oct 2, 2017
1 parent 0ccd97c commit c3af53d
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/3D Models Coloring.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
viewer.entities.removeAll();

var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
var heading = Cesium.Math.toRadians(135);
var heading = -Cesium.Math.toRadians(135);
var pitch = 0;
var roll = 0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
Expand Down
6 changes: 3 additions & 3 deletions Apps/Sandcastle/gallery/Classification.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

var center = new Cesium.Cartesian3(1216378.730451297, -4736275.917774027, 4081266.871000864);
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center);
var hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(2.619728786416368, 0.0, 0.0));
var hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(-2.619728786416368, 0.0, 0.0));
var hpr = Cesium.Matrix4.fromRotationTranslation(hprRotation, new Cesium.Cartesian3(0.0, 0.0, -2.0));
Cesium.Matrix4.multiply(modelMatrix, hpr, modelMatrix);

Expand Down Expand Up @@ -91,7 +91,7 @@

var center = new Cesium.Cartesian3(1216398.6054139996, -4736204.533089285, 4081338.6585485404);
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center);
var hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(5.785339046755887, 0.0, 0.0));
var hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(-5.785339046755887, 0.0, 0.0));
var hpr = Cesium.Matrix4.fromRotationTranslation(hprRotation, new Cesium.Cartesian3(0.4, 0.0, -2.0));
Cesium.Matrix4.multiply(modelMatrix, hpr, modelMatrix);

Expand All @@ -111,7 +111,7 @@

center = new Cesium.Cartesian3(1216394.3346955755, -4736207.431365568, 4081336.7768881875);
modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center);
hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(5.785339046755887, 0.0, 0.0));
hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(-5.785339046755887, 0.0, 0.0));
hpr = Cesium.Matrix4.fromRotationTranslation(hprRotation, new Cesium.Cartesian3(-0.25, 0.0, -2.0));
Cesium.Matrix4.multiply(modelMatrix, hpr, modelMatrix);

Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Distance Display Conditions.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

var position = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883, 0.0);
var heading = Cesium.Math.toRadians(135);
var hpr = new Cesium.HeadingPitchRoll(heading, 0.0, 0.0);
var hpr = new Cesium.HeadingPitchRoll(-heading, 0.0, 0.0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);

viewer.entities.add({
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Projection.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
viewer.projectionPicker.viewModel.switchToOrthographic();

var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 0.0);
var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(135), 0.0, 0.0);
var hpr = new Cesium.HeadingPitchRoll(-Cesium.Math.toRadians(135), 0.0, 0.0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);

var entity = viewer.entities.add({
Expand Down
4 changes: 2 additions & 2 deletions Apps/Sandcastle/gallery/development/3D Models.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@

function createModel(url, height, heading, pitch, roll) {
height = Cesium.defaultValue(height, 0.0);
heading = Cesium.defaultValue(heading, 0.0);
pitch = Cesium.defaultValue(pitch, 0.0);
heading = -Cesium.defaultValue(heading, 0.0);
pitch = -Cesium.defaultValue(pitch, 0.0);
roll = Cesium.defaultValue(roll, 0.0);
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);

Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Change Log
### 1.38 - 2017-10-02

* Breaking changes
* `HeadingPitchRoll.fromQuaternion`, `Matrix3.fromHeadingPitchRoll`, `Quaternion.fromHeadingPitchRoll`, `Transforms.headingPitchRollToFixedFrame`, and `Transforms.headingPitchRollQuaternion` now use the classical orientation of heading and pitch calculated counter-clockwise. With this new behavior, heading and pitch need to be the negative of their previous values. The warning message will be removed in Cesium 1.40.[#5666](https:/AnalyticalGraphicsInc/cesium/issues/5666)
* `Scene/CullingVolume` has been removed. Use `Core/CullingVolume`.
* `Scene/OrthographicFrustum` has been removed. Use `Core/OrthographicFrustum`.
* `Scene/OrthographicOffCenterFrustum` has been removed. Use `Core/OrthographicOffCenterFrustum`.
Expand Down
16 changes: 12 additions & 4 deletions Source/Core/HeadingPitchRoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ define([
'./defaultValue',
'./defined',
'./DeveloperError',
'./Math'
'./Math',
'./deprecationWarning'
], function(
defaultValue,
defined,
DeveloperError,
CesiumMath) {
CesiumMath,
deprecationWarning) {
'use strict';

/**
Expand Down Expand Up @@ -40,17 +42,23 @@ define([
throw new DeveloperError('quaternion is required');
}
//>>includeEnd('debug');

deprecationWarning('HeadingPitchRoll.fromQuaternion', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.');

if (!defined(result)) {
result = new HeadingPitchRoll();
}

var test = 2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x);
var denominatorRoll = 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y);
var numeratorRoll = 2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z);
var denominatorHeading = 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z);
var numeratorHeading = 2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y);
result.heading = -Math.atan2(numeratorHeading, denominatorHeading);

result.heading = Math.atan2(numeratorHeading, denominatorHeading);
result.roll = Math.atan2(numeratorRoll, denominatorRoll);
result.pitch = -Math.asin(test);
result.pitch = Math.asin(test);

return result;
};

Expand Down
16 changes: 10 additions & 6 deletions Source/Core/Matrix3.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ define([
'./defineProperties',
'./DeveloperError',
'./freezeObject',
'./Math'
'./Math',
'./deprecationWarning'
], function(
Cartesian3,
Check,
Expand All @@ -15,7 +16,8 @@ define([
defineProperties,
DeveloperError,
freezeObject,
CesiumMath) {
CesiumMath,
deprecationWarning) {
'use strict';

/**
Expand Down Expand Up @@ -304,11 +306,13 @@ define([
Check.typeOf.object('headingPitchRoll', headingPitchRoll);
//>>includeEnd('debug');

var cosTheta = Math.cos(-headingPitchRoll.pitch);
var cosPsi = Math.cos(-headingPitchRoll.heading);
deprecationWarning('Matrix3.fromHeadingPitchRoll', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.');

var cosTheta = Math.cos(headingPitchRoll.pitch);
var cosPsi = Math.cos(headingPitchRoll.heading);
var cosPhi = Math.cos(headingPitchRoll.roll);
var sinTheta = Math.sin(-headingPitchRoll.pitch);
var sinPsi = Math.sin(-headingPitchRoll.heading);
var sinTheta = Math.sin(headingPitchRoll.pitch);
var sinPsi = Math.sin(headingPitchRoll.heading);
var sinPhi = Math.sin(headingPitchRoll.roll);

var m00 = cosTheta * cosPsi;
Expand Down
13 changes: 9 additions & 4 deletions Source/Core/Quaternion.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ define([
'./freezeObject',
'./HeadingPitchRoll',
'./Math',
'./Matrix3'
'./Matrix3',
'./deprecationWarning'
], function(
Cartesian3,
Check,
Expand All @@ -17,7 +18,8 @@ define([
freezeObject,
HeadingPitchRoll,
CesiumMath,
Matrix3) {
Matrix3,
deprecationWarning) {
'use strict';

/**
Expand Down Expand Up @@ -189,10 +191,13 @@ define([
Check.typeOf.object('headingPitchRoll', headingPitchRoll);
//>>includeEnd('debug');

deprecationWarning('Quaternion.fromHeadingPitchRoll', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.');

scratchRollQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_X, headingPitchRoll.roll, scratchHPRQuaternion);
scratchPitchQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_Y, -headingPitchRoll.pitch, result);
scratchPitchQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_Y, headingPitchRoll.pitch, result);
result = Quaternion.multiply(scratchPitchQuaternion, scratchRollQuaternion, scratchPitchQuaternion);
scratchHeadingQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_Z, -headingPitchRoll.heading, scratchHPRQuaternion);
scratchHeadingQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_Z, headingPitchRoll.heading, scratchHPRQuaternion);

return Quaternion.multiply(scratchHeadingQuaternion, result, result);
};

Expand Down
17 changes: 14 additions & 3 deletions Source/Core/Transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ define([
'./Matrix3',
'./Matrix4',
'./Quaternion',
'./TimeConstants'
'./TimeConstants',
'./deprecationWarning'
], function(
when,
Cartesian2,
Expand All @@ -39,7 +40,8 @@ define([
Matrix3,
Matrix4,
Quaternion,
TimeConstants) {
TimeConstants,
deprecationWarning) {
'use strict';

/**
Expand Down Expand Up @@ -334,8 +336,12 @@ define([
Check.typeOf.object( 'HeadingPitchRoll', headingPitchRoll);
//>>includeEnd('debug');

deprecationWarning('Transforms.headingPitchRollToFixedFrame', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.');

fixedFrameTransform = defaultValue(fixedFrameTransform, Transforms.eastNorthUpToFixedFrame);
var hprQuaternion = Quaternion.fromHeadingPitchRoll(headingPitchRoll, scratchHPRQuaternion);

var hprQuaternion = Quaternion.fromHeadingPitchRoll(headingPitchRoll, scratchHPRQuaternion);

var hprMatrix = Matrix4.fromTranslationQuaternionRotationScale(Cartesian3.ZERO, hprQuaternion, scratchScale, scratchHPRMatrix4);
result = fixedFrameTransform(origin, ellipsoid, result);
return Matrix4.multiply(result, hprMatrix, result);
Expand Down Expand Up @@ -372,6 +378,11 @@ define([
Check.typeOf.object( 'HeadingPitchRoll', headingPitchRoll);
//>>includeEnd('debug');

deprecationWarning('Transforms.headingPitchRollQuaternion', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.');

scratchENUMatrix4 = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, scratchENUMatrix4);
Matrix4.getRotation(scratchENUMatrix4, scratchHPRMatrix3);

var transform = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, scratchENUMatrix4);
var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3);
return Quaternion.fromRotationMatrix(rotation, result);
Expand Down
20 changes: 9 additions & 11 deletions Source/Scene/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,6 @@ define([
var scratchSetViewCartesian = new Cartesian3();
var scratchSetViewTransform1 = new Matrix4();
var scratchSetViewTransform2 = new Matrix4();
var scratchSetViewQuaternion = new Quaternion();
var scratchSetViewMatrix3 = new Matrix3();
var scratchSetViewCartographic = new Cartographic();

Expand All @@ -1049,10 +1048,10 @@ define([
camera._setTransform(localTransform);

Cartesian3.clone(Cartesian3.ZERO, camera.position);
hpr.heading = hpr.heading - CesiumMath.PI_OVER_TWO;
hpr.heading = -hpr.heading + CesiumMath.PI_OVER_TWO;
hpr.pitch = -hpr.pitch;

var rotQuat = Quaternion.fromHeadingPitchRoll(hpr, scratchSetViewQuaternion);
var rotMat = Matrix3.fromQuaternion(rotQuat, scratchSetViewMatrix3);
var rotMat = Matrix3.fromHeadingPitchRoll(hpr, scratchSetViewMatrix3);

Matrix3.getColumn(rotMat, 0, camera.direction);
Matrix3.getColumn(rotMat, 2, camera.up);
Expand All @@ -1075,10 +1074,10 @@ define([
}
Cartesian3.clone(position, camera.position);
}
hpr.heading = hpr.heading - CesiumMath.PI_OVER_TWO;
hpr.heading = -hpr.heading + CesiumMath.PI_OVER_TWO;
hpr.pitch = -hpr.pitch;

var rotQuat = Quaternion.fromHeadingPitchRoll(hpr, scratchSetViewQuaternion);
var rotMat = Matrix3.fromQuaternion(rotQuat, scratchSetViewMatrix3);
var rotMat = Matrix3.fromHeadingPitchRoll(hpr, scratchSetViewMatrix3);

Matrix3.getColumn(rotMat, 0, camera.direction);
Matrix3.getColumn(rotMat, 2, camera.up);
Expand Down Expand Up @@ -1116,11 +1115,10 @@ define([
}

if (camera._scene.mapMode2D === MapMode2D.ROTATE) {
hpr.heading = hpr.heading - CesiumMath.PI_OVER_TWO;
hpr.pitch = -CesiumMath.PI_OVER_TWO;
hpr.heading = -hpr.heading + CesiumMath.PI_OVER_TWO;
hpr.pitch = CesiumMath.PI_OVER_TWO;
hpr.roll = 0.0;
var rotQuat = Quaternion.fromHeadingPitchRoll(hpr, scratchSetViewQuaternion);
var rotMat = Matrix3.fromQuaternion(rotQuat, scratchSetViewMatrix3);
var rotMat = Matrix3.fromHeadingPitchRoll(hpr, scratchSetViewMatrix3);

Matrix3.getColumn(rotMat, 2, camera.up);
Cartesian3.cross(camera.direction, camera.up, camera.right);
Expand Down
2 changes: 1 addition & 1 deletion Specs/Core/Matrix3Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ defineSuite([
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 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);
Expand Down
12 changes: 6 additions & 6 deletions Specs/Core/QuaternionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ defineSuite([
var angle = CesiumMath.toRadians(20.0);
var hpr = new HeadingPitchRoll(angle, 0.0, 0.0);
var quaternion = Quaternion.fromHeadingPitchRoll(hpr);
expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(Matrix3.fromRotationZ(-angle), CesiumMath.EPSILON11);
expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(Matrix3.fromRotationZ(angle), CesiumMath.EPSILON11);
});

it('fromHeadingPitchRoll with just pitch', function() {
var angle = CesiumMath.toRadians(20.0);
var hpr = new HeadingPitchRoll(0.0, angle, 0.0);
var quaternion = Quaternion.fromHeadingPitchRoll(hpr);
expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(Matrix3.fromRotationY(-angle), CesiumMath.EPSILON11);
expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(Matrix3.fromRotationY(angle), CesiumMath.EPSILON11);
});

it('fromHeadingPitchRoll with just roll', function() {
Expand All @@ -130,8 +130,8 @@ defineSuite([
var hpr = new HeadingPitchRoll( angle, angle, angle);
var quaternion = Quaternion.fromHeadingPitchRoll(hpr);
var expected = Matrix3.fromRotationX(angle);
Matrix3.multiply(Matrix3.fromRotationY(-angle), expected, expected);
Matrix3.multiply(Matrix3.fromRotationZ(-angle), expected, expected);
Matrix3.multiply(Matrix3.fromRotationY(angle), expected, expected);
Matrix3.multiply(Matrix3.fromRotationZ(angle), expected, expected);
expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(expected, CesiumMath.EPSILON11);
});

Expand All @@ -142,8 +142,8 @@ defineSuite([
var hpr = new HeadingPitchRoll( heading, pitch, roll);
var quaternion = Quaternion.fromHeadingPitchRoll(hpr);
var expected = Matrix3.fromRotationX(roll);
Matrix3.multiply(Matrix3.fromRotationY(-pitch), expected, expected);
Matrix3.multiply(Matrix3.fromRotationZ(-heading), expected, expected);
Matrix3.multiply(Matrix3.fromRotationY(pitch), expected, expected);
Matrix3.multiply(Matrix3.fromRotationZ(heading), expected, expected);
expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(expected, CesiumMath.EPSILON11);
});

Expand Down
5 changes: 2 additions & 3 deletions Specs/Core/TransformsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ defineSuite([
expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON11);
});


it('headingPitchRollQuaternion works with a custom fixedFrameTransform', function() {
var origin = new Cartesian3(1.0, 0.0, 0.0);
var heading = CesiumMath.toRadians(20.0);
Expand Down Expand Up @@ -1048,7 +1047,7 @@ defineSuite([
var heading = CesiumMath.toRadians(90.0);
var pitch = CesiumMath.toRadians(45.0);
var roll = 0.0;
var hpr = new HeadingPitchRoll(heading, pitch, roll);
var hpr = new HeadingPitchRoll(-heading, -pitch, roll);

var modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid);
var modelMatrix2D = Transforms.basisTo2D(projection, modelMatrix, new Matrix4());
Expand All @@ -1069,7 +1068,7 @@ defineSuite([
var heading = CesiumMath.toRadians(90.0);
var pitch = CesiumMath.toRadians(45.0);
var roll = 0.0;
var hpr = new HeadingPitchRoll(heading, pitch, roll);
var hpr = new HeadingPitchRoll(-heading, -pitch, roll);

var modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid);
var modelMatrix2D = Transforms.basisTo2D(projection, modelMatrix, new Matrix4());
Expand Down
2 changes: 1 addition & 1 deletion Specs/Scene/ModelInstanceCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ defineSuite([
var heading = Math.PI/2.0;
var pitch = 0.0;
var roll = 0.0;
var hpr = new HeadingPitchRoll(heading, pitch, roll);
var hpr = new HeadingPitchRoll(-heading, -pitch, roll);
var modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpr);
instances.push({
modelMatrix : modelMatrix
Expand Down

0 comments on commit c3af53d

Please sign in to comment.