Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove separate heading, pitch, roll from Transform #4843

Merged
merged 7 commits into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Change Log
### 1.30 - 2017-02-01
* Deprecated
* The properties `url` and `key` will be removed from `GeocoderViewModel` in 1.31. These properties will be available on geocoder services that support them, like `BingMapsGeocoderService`.
* Breaking changes
* Removed separate `heading`, `pitch`, `roll` parameters from `Transform.headingPitchRollToFixedFrame` and `Transform.headingPitchRollQuaternion`. Pass a `headingPitchRoll` object instead. [#4843](https://github.com/AnalyticalGraphicsInc/cesium/pull/4843)
* Added support for custom geocoder services and autocomplete [#4723](https://github.com/AnalyticalGraphicsInc/cesium/pull/4723).
* Added [Custom Geocoder Sandcastle example](http://localhost:8080/Apps/Sandcastle/index.html?src=Custom%20Geocoder.html)
* Added `GeocoderService`, an interface for geocoders.
Expand Down
42 changes: 11 additions & 31 deletions Source/Core/Transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ define([
'./Cartesian3',
'./Cartesian4',
'./Cartographic',
'./Check',
'./defaultValue',
'./defined',
'./deprecationWarning',
'./DeveloperError',
'./EarthOrientationParameters',
'./EarthOrientationParametersSample',
Expand All @@ -27,9 +27,9 @@ define([
Cartesian3,
Cartesian4,
Cartographic,
Check,
defaultValue,
defined,
deprecationWarning,
DeveloperError,
EarthOrientationParameters,
EarthOrientationParametersSample,
Expand Down Expand Up @@ -473,27 +473,19 @@ define([
* var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
* var transform = Cesium.Transforms.headingPitchRollToFixedFrame(center, hpr);
*/
Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, pitch, roll, ellipsoid, result) {
var heading;
if (typeof headingPitchRoll === 'object') {
// Shift arguments using assignments to encourage JIT optimization.
ellipsoid = pitch;
result = roll;
heading = headingPitchRoll.heading;
pitch = headingPitchRoll.pitch;
roll = headingPitchRoll.roll;
} else {
deprecationWarning('headingPitchRollToFixedFrame', 'headingPitchRollToFixedFrame with separate heading, pitch, and roll arguments was deprecated in 1.27. It will be removed in 1.30. Use a HeadingPitchRoll object.');
heading = headingPitchRoll;
}
Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, ellipsoid, result) {
Check.typeOf.object(headingPitchRoll, 'headingPitchRoll');
var heading = headingPitchRoll.heading;
var pitch = headingPitchRoll.pitch;
var roll = headingPitchRoll.roll;

// checks for required parameters happen in the called functions
var hprQuaternion = Quaternion.fromHeadingPitchRoll(heading, pitch, roll, scratchHPRQuaternion);
var hprMatrix = Matrix4.fromTranslationQuaternionRotationScale(Cartesian3.ZERO, hprQuaternion, scratchScale, scratchHPRMatrix4);
result = Transforms.eastNorthUpToFixedFrame(origin, ellipsoid, result);
return Matrix4.multiply(result, hprMatrix, result);
};

var scratchHPR = new HeadingPitchRoll();
var scratchENUMatrix4 = new Matrix4();
var scratchHPRMatrix3 = new Matrix3();

Expand All @@ -518,22 +510,10 @@ define([
* var hpr = new HeadingPitchRoll(heading, pitch, roll);
* var quaternion = Cesium.Transforms.headingPitchRollQuaternion(center, hpr);
*/
Transforms.headingPitchRollQuaternion = function(origin, headingPitchRoll, pitch, roll, ellipsoid, result) {
var hpr;
if (typeof headingPitchRoll === 'object') {
// Shift arguments using assignment to encourage JIT optimization.
hpr = headingPitchRoll;
ellipsoid = pitch;
result = roll;
} else {
deprecationWarning('headingPitchRollQuaternion', 'headingPitchRollQuaternion with separate heading, pitch, and roll arguments was deprecated in 1.27. It will be removed in 1.30. Use a HeadingPitchRoll object.');
scratchHPR.heading = headingPitchRoll;
scratchHPR.pitch = pitch;
scratchHPR.roll = roll;
hpr = scratchHPR;
}
Transforms.headingPitchRollQuaternion = function(origin, headingPitchRoll, ellipsoid, result) {
// checks for required parameters happen in the called functions
var transform = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid, scratchENUMatrix4);
Check.typeOf.object(headingPitchRoll, 'headingPitchRoll');
var transform = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, scratchENUMatrix4);
var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3);
return Quaternion.fromRotationMatrix(rotation, result);
};
Expand Down
20 changes: 4 additions & 16 deletions Specs/Core/TransformsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ defineSuite([
var transform = Transforms.headingPitchRollToFixedFrame(origin, hpr, Ellipsoid.UNIT_SPHERE);
var expected = Matrix4.getRotation(transform, new Matrix3());

var quaternion = Transforms.headingPitchRollQuaternion(origin, heading, pitch, roll, Ellipsoid.UNIT_SPHERE);
var quaternion = Transforms.headingPitchRollQuaternion(origin, hpr, Ellipsoid.UNIT_SPHERE);
var actual = Matrix3.fromQuaternion(quaternion);
expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON11);
});
Expand Down Expand Up @@ -388,7 +388,7 @@ defineSuite([
var expected = Matrix4.getRotation(transform, new Matrix3());

var result = new Quaternion();
var quaternion = Transforms.headingPitchRollQuaternion(origin, heading, pitch, roll, Ellipsoid.UNIT_SPHERE, result);
var quaternion = Transforms.headingPitchRollQuaternion(origin, hpr, Ellipsoid.UNIT_SPHERE, result);
var actual = Matrix3.fromQuaternion(quaternion);
expect(quaternion).toBe(result);
expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON11);
Expand Down Expand Up @@ -923,21 +923,9 @@ defineSuite([
}).toThrowDeveloperError();
});

it('headingPitchRollToFixedFrame throws without an heading', function() {
expect(function() {
Transforms.headingPitchRollToFixedFrame(Cartesian3.ZERO, undefined, 0.0, 0.0);
}).toThrowDeveloperError();
});

it('headingPitchRollToFixedFrame throws without an pitch', function() {
expect(function() {
Transforms.headingPitchRollToFixedFrame(Cartesian3.ZERO, 0.0, undefined, 0.0);
}).toThrowDeveloperError();
});

it('headingPitchRollToFixedFrame throws without an roll', function() {
it('headingPitchRollToFixedFrame throws without a headingPitchRoll', function() {
expect(function() {
Transforms.headingPitchRollToFixedFrame(Cartesian3.ZERO, 0.0, 0.0, undefined);
Transforms.headingPitchRollToFixedFrame(Cartesian3.ZERO, undefined);
}).toThrowDeveloperError();
});

Expand Down