diff --git a/Apps/Sandcastle/gallery/3D Models.html b/Apps/Sandcastle/gallery/3D Models.html
index 577880df487c..30caabdb7188 100644
--- a/Apps/Sandcastle/gallery/3D Models.html
+++ b/Apps/Sandcastle/gallery/3D Models.html
@@ -40,7 +40,8 @@
var heading = Cesium.Math.toRadians(135);
var pitch = 0;
var roll = 0;
- var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, heading, pitch, roll);
+ var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
+ var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
var entity = viewer.entities.add({
name : url,
diff --git a/Apps/Sandcastle/gallery/Distance Display Conditions.html b/Apps/Sandcastle/gallery/Distance Display Conditions.html
index 988e9eb62a3c..d4475cabe5d8 100644
--- a/Apps/Sandcastle/gallery/Distance Display Conditions.html
+++ b/Apps/Sandcastle/gallery/Distance Display Conditions.html
@@ -54,7 +54,8 @@
var position = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883, 0.0);
var heading = Cesium.Math.toRadians(135);
- var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, 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({
position : position,
diff --git a/Apps/Sandcastle/gallery/development/3D Models Node Explorer.html b/Apps/Sandcastle/gallery/development/3D Models Node Explorer.html
index 0c3a2bf340c2..e9bf3a982bcf 100644
--- a/Apps/Sandcastle/gallery/development/3D Models Node Explorer.html
+++ b/Apps/Sandcastle/gallery/development/3D Models Node Explorer.html
@@ -181,11 +181,8 @@
var scene = viewer.scene;
var height = 250000.0;
-var heading = 0.0;
-var pitch = 0.0;
-var roll = 0.0;
var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
-var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll);
+var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, new Cesium.HeadingPitchRoll());
var model = scene.primitives.add(Cesium.Model.fromGltf({
url : modelUrl,
diff --git a/Apps/Sandcastle/gallery/development/3D Models.html b/Apps/Sandcastle/gallery/development/3D Models.html
index d74e03952e41..0504f5af2a7b 100644
--- a/Apps/Sandcastle/gallery/development/3D Models.html
+++ b/Apps/Sandcastle/gallery/development/3D Models.html
@@ -35,9 +35,10 @@
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);
var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
- var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll);
+ var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, hpr);
scene.primitives.removeAll(); // Remove previous model
var model = scene.primitives.add(Cesium.Model.fromGltf({
diff --git a/Apps/Sandcastle/gallery/development/HeadingPitchRoll.html b/Apps/Sandcastle/gallery/development/HeadingPitchRoll.html
index 148bc91fb8ad..a58c6fae485e 100644
--- a/Apps/Sandcastle/gallery/development/HeadingPitchRoll.html
+++ b/Apps/Sandcastle/gallery/development/HeadingPitchRoll.html
@@ -107,7 +107,7 @@
Loading...
var planePrimitive = scene.primitives.add(Cesium.Model.fromGltf({
url : '../../SampleData/models/CesiumAir/Cesium_Air.glb',
- modelMatrix : Cesium.Transforms.aircraftHeadingPitchRollToFixedFrame(position, hpRoll),
+ modelMatrix : Cesium.Transforms.headingPitchRollToFixedFrame(position, hpRoll),
minimumPixelSize : 128
}));
@@ -208,7 +208,7 @@ Loading...
speedVector = Cesium.Cartesian3.multiplyByScalar(Cesium.Cartesian3.UNIT_X, speed / 10, speedVector);
position = Cesium.Matrix4.multiplyByPoint(planePrimitive.modelMatrix, speedVector, position);
pathPosition.addSample(Cesium.JulianDate.now(), position);
- Cesium.Transforms.aircraftHeadingPitchRollToFixedFrame(position, hpRoll, undefined, planePrimitive.modelMatrix);
+ Cesium.Transforms.headingPitchRollToFixedFrame(position, hpRoll, undefined, planePrimitive.modelMatrix);
if (fromBehind.checked) {
// Zoom to model
diff --git a/Apps/Sandcastle/gallery/development/Multiple Shadows.html b/Apps/Sandcastle/gallery/development/Multiple Shadows.html
index 3794a9b205d0..798300e8c765 100644
--- a/Apps/Sandcastle/gallery/development/Multiple Shadows.html
+++ b/Apps/Sandcastle/gallery/development/Multiple Shadows.html
@@ -74,7 +74,7 @@
var model = scene.primitives.add(Cesium.Model.fromGltf({
url : '../../SampleData/models/ShadowTester/Shadow_Tester_Point.gltf',
- modelMatrix : Cesium.Transforms.headingPitchRollToFixedFrame(center, heading, 0.0, 0.0)
+ modelMatrix : Cesium.Transforms.headingPitchRollToFixedFrame(center, new Cesium.HeadingPitchRoll(heading, 0.0, 0.0))
}));
model.readyPromise.then(function(model) {
diff --git a/Apps/Sandcastle/gallery/development/Shadows.html b/Apps/Sandcastle/gallery/development/Shadows.html
index 91d9640a257d..86c743789516 100644
--- a/Apps/Sandcastle/gallery/development/Shadows.html
+++ b/Apps/Sandcastle/gallery/development/Shadows.html
@@ -585,7 +585,7 @@
}
function createModel(url, origin) {
- var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, 0.0, 0.0, 0.0);
+ var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, new Cesium.HeadingPitchRoll());
var model = scene.primitives.add(Cesium.Model.fromGltf({
url : url,
@@ -606,7 +606,7 @@
}
function createBoxRTC(origin) {
- var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, 0.0, 0.0, 0.0);
+ var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, new Cesium.HeadingPitchRoll());
var boxGeometry = Cesium.BoxGeometry.createGeometry(Cesium.BoxGeometry.fromDimensions({
vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
@@ -645,7 +645,7 @@
}
function createBox(origin) {
- var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, 0.0, 0.0, 0.0);
+ var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, new Cesium.HeadingPitchRoll());
var box = new Cesium.Primitive({
geometryInstances : new Cesium.GeometryInstance({
@@ -670,7 +670,7 @@
}
function createSphere(origin) {
- var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, 0.0, 0.0, 0.0);
+ var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, new Cesium.HeadingPitchRoll());
var sphere = new Cesium.Primitive({
geometryInstances : new Cesium.GeometryInstance({
diff --git a/CHANGES.md b/CHANGES.md
index b85cd9b0a27f..13cf67be9650 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -24,14 +24,13 @@ Change Log
* Removed an unnecessary reprojection of Web Mercator imagery tiles to the Geographic projection on load. This should improve both visual quality and load performance slightly.
* Fix a issue where a billboard entity would not render after toggling the show propery. [#4408](https://github.com/AnalyticalGraphicsInc/cesium/issues/4408)
* Added `Transforms.northUpEastToFixedFrame` to compute a 4x4 local transformation matrix from a reference frame with an north-west-up axes.
-* Added `Transforms.aircraftHeadingPitchRollToFixedFrame` to create a local frame from a position and heading/pitch/roll angles. The local frame is north-west-up axed.
-* Added `Transforms.aircraftHeadingPitchRollQuaternion` which is the quaternion rotation from `Transforms.aircraftHeadingPitchRollToFixedFrame`.
* Added `HeadingPitchRoll` :
* `HeadingPitchRoll.fromQuaternion` function for retrieving heading-pitch-roll angles from a quaternion.
* `HeadingPitchRoll.fromDegrees` function that returns a new HeadingPitchRoll instance from angles given in degrees.
* `HeadingPitchRoll.clone` function to duplicate HeadingPitchRoll instance.
* `HeadingPitchRoll.equals` and `HeadingPitchRoll.equalsEpsilon` functions for comparing two instances.
* Added `Matrix3.fromHeadingPitchRoll` Computes a 3x3 rotation matrix from the provided headingPitchRoll.
+* `Transforms.headingPitchRollToFixedFrame` and `Transforms.headingPitchRollQuaternion` now take a `HeadingPitchRoll` object in addition to separate heading, pitch, and roll values. Separate values will be deprecated in 1.30.
### 1.26 - 2016-10-03
diff --git a/Source/Core/Transforms.js b/Source/Core/Transforms.js
index 4c5b1a12900b..8c95db4c8d88 100644
--- a/Source/Core/Transforms.js
+++ b/Source/Core/Transforms.js
@@ -7,6 +7,7 @@ define([
'./Cartographic',
'./defaultValue',
'./defined',
+ './deprecationWarning',
'./DeveloperError',
'./EarthOrientationParameters',
'./EarthOrientationParametersSample',
@@ -28,6 +29,7 @@ define([
Cartographic,
defaultValue,
defined,
+ deprecationWarning,
DeveloperError,
EarthOrientationParameters,
EarthOrientationParametersSample,
@@ -457,9 +459,7 @@ define([
* are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.
*
* @param {Cartesian3} origin The center point of the local reference frame.
- * @param {Number} heading The heading angle in radians.
- * @param {Number} pitch The pitch angle in radians.
- * @param {Number} roll The roll angle in radians.
+ * @param {HeadingPitchRoll} headingPitchRoll The heading, pitch, and roll.
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.
* @param {Matrix4} [result] The object onto which to store the result.
* @returns {Matrix4} The modified result parameter or a new Matrix4 instance if none was provided.
@@ -472,7 +472,19 @@ define([
* var roll = 0.0;
* var transform = Cesium.Transforms.headingPitchRollToFixedFrame(center, heading, pitch, roll);
*/
- Transforms.headingPitchRollToFixedFrame = function(origin, heading, pitch, roll, ellipsoid, result) {
+ 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;
+ }
// 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);
@@ -480,43 +492,7 @@ define([
return Matrix4.multiply(result, hprMatrix, result);
};
- /**
- * Computes a 4x4 transformation matrix from a reference frame with axes computed from the heading-pitch-roll angles
- * centered at the provided origin to the provided ellipsoid's fixed reference frame. Heading is the rotation from the local north
- * direction where a positive angle is increasing eastward. Pitch is the rotation from the local east-north plane. Positive pitch angles
- * are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.
- *
- * @param {Cartesian3} origin The center point of the local reference frame.
- * @param {HeadingPitchRoll} headingPitchRoll The heading, pitch, roll angles to apply.
- * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.
- * @param {Matrix4} [result] The object onto which to store the result.
- * @returns {Matrix4} The modified result parameter or a new Matrix4 instance if none was provided.
- *
- * @example
- * // Get the transform from local heading-pitch-roll at cartographic (0.0, 0.0) to Earth's fixed frame.
- * var center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
- * var hpr = new HeadingPitchRoll(0.0, 0.0, 0.0);
- * var hpr.heading = -Cesium.Math.PI_OVER_TWO;
- * var hpr.pitch = Cesium.Math.PI_OVER_FOUR;
- * var hpr.roll = 0.0;
- * var transform = Cesium.Transforms.aircraftHeadingPitchRollToFixedFrame(center, hpr);
- */
- Transforms.aircraftHeadingPitchRollToFixedFrame = function(origin, headingPitchRoll, ellipsoid, result) {
- // checks for required parameters happen in the called functions
- //>>includeStart('debug', pragmas.debug);
- if (!defined(origin)) {
- throw new DeveloperError('origin is required.');
- }
- if (!defined(headingPitchRoll)) {
- throw new DeveloperError('headingPitchRoll is required.');
- }
- //>>includeEnd('debug');
- var hprQuaternion = Quaternion.fromHeadingPitchRoll(headingPitchRoll.heading, headingPitchRoll.pitch, headingPitchRoll.roll, scratchHPRQuaternion);
- var hprMatrix = Matrix4.fromTranslationQuaternionRotationScale(Cartesian3.ZERO, hprQuaternion, scratchScale, scratchHPRMatrix4);
- result = Transforms.northWestUpToFixedFrame(origin, ellipsoid, result);
- return Matrix4.multiply(result, hprMatrix, result);
- };
-
+ var scratchHPR = new HeadingPitchRoll();
var scratchENUMatrix4 = new Matrix4();
var scratchHPRMatrix3 = new Matrix3();
@@ -527,9 +503,7 @@ define([
* are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.
*
* @param {Cartesian3} origin The center point of the local reference frame.
- * @param {Number} heading The heading angle in radians.
- * @param {Number} pitch The pitch angle in radians.
- * @param {Number} roll The roll angle in radians.
+ * @param {HeadingPitchRoll} headingPitchRoll The heading, pitch, and roll.
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.
* @param {Quaternion} [result] The object onto which to store the result.
* @returns {Quaternion} The modified result parameter or a new Quaternion instance if none was provided.
@@ -540,41 +514,25 @@ define([
* var heading = -Cesium.Math.PI_OVER_TWO;
* var pitch = Cesium.Math.PI_OVER_FOUR;
* var roll = 0.0;
- * var quaternion = Cesium.Transforms.headingPitchRollQuaternion(center, heading, pitch, roll);
- */
- Transforms.headingPitchRollQuaternion = function(origin, heading, pitch, roll, ellipsoid, result) {
- // checks for required parameters happen in the called functions
- var transform = Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll, ellipsoid, scratchENUMatrix4);
- var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3);
- return Quaternion.fromRotationMatrix(rotation, result);
- };
-
- /**
- * Computes a quaternion from a reference frame with axes computed from the heading-pitch-roll angles
- * centered at the provided origin. Heading is the rotation from the local north
- * direction where a positive angle is increasing eastward. Pitch is the rotation from the local east-north plane. Positive pitch angles
- * are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.
- *
- * @param {Cartesian3} origin The center point of the local reference frame.
- * @param {HeadingPitchRoll} headingPitchRoll The heading, pitch, roll angles to apply.
- * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.
- * @param {Quaternion} [result] The object onto which to store the result.
- * @returns {Quaternion} The modified result parameter or a new Quaternion instance if none was provided.
- *
- * @example
- * // Get the quaternion from local heading-pitch-roll at cartographic (0.0, 0.0) to Earth's fixed frame.
- * var center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
- * var hpr = new HeadingPitchRoll(0.0, 0.0, 0.0);
- * var hpr.heading = -Cesium.Math.PI_OVER_TWO;
- * var hpr.pitch = Cesium.Math.PI_OVER_FOUR;
- * var hpr.roll = 0.0;
- * var quaternion = Cesium.Transforms.aircraftHeadingPitchRollQuaternion(center, hpr);
- *
- *
+ * var hpr = new HeadingPitchRoll(heading, pitch, roll);
+ * var quaternion = Cesium.Transforms.headingPitchRollQuaternion(center, hpr);
*/
- Transforms.aircraftHeadingPitchRollQuaternion = function(origin, headingPitchRoll, ellipsoid, result) {
+ 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;
+ }
// checks for required parameters happen in the called functions
- var transform = Transforms.aircraftHeadingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, scratchENUMatrix4);
+ var transform = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid, scratchENUMatrix4);
var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3);
return Quaternion.fromRotationMatrix(rotation, result);
};
diff --git a/Specs/Core/TransformsSpec.js b/Specs/Core/TransformsSpec.js
index 2fc0a2d48394..40221fc9bc1f 100644
--- a/Specs/Core/TransformsSpec.js
+++ b/Specs/Core/TransformsSpec.js
@@ -46,7 +46,6 @@ defineSuite([
var negativeX = new Cartesian4(-1, 0, 0, 0);
var negativeY = new Cartesian4(0, -1, 0, 0);
var negativeZ = new Cartesian4(0, 0, -1, 0);
- var scratchHeadingPitchRoll = new Quaternion();
it('eastNorthUpToFixedFrame works without a result parameter', function() {
var origin = new Cartesian3(1.0, 0.0, 0.0);
@@ -245,6 +244,7 @@ defineSuite([
var heading = CesiumMath.toRadians(20.0);
var pitch = CesiumMath.toRadians(30.0);
var roll = CesiumMath.toRadians(40.0);
+ var hpr = new HeadingPitchRoll(heading, pitch, roll);
var expectedRotation = Matrix3.fromQuaternion(Quaternion.fromHeadingPitchRoll(heading, pitch, roll));
var expectedX = Matrix3.getColumn(expectedRotation, 0, new Cartesian3());
@@ -255,7 +255,7 @@ defineSuite([
Cartesian3.fromElements(expectedY.z, expectedY.x, expectedY.y, expectedY);
Cartesian3.fromElements(expectedZ.z, expectedZ.x, expectedZ.y, expectedZ);
- var returnedResult = Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll, Ellipsoid.UNIT_SPHERE);
+ var returnedResult = Transforms.headingPitchRollToFixedFrame(origin, hpr, Ellipsoid.UNIT_SPHERE);
var actualX = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 0, new Cartesian4()));
var actualY = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 1, new Cartesian4()));
var actualZ = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 2, new Cartesian4()));
@@ -267,11 +267,12 @@ defineSuite([
expect(actualTranslation).toEqual(origin);
});
- it('headingPitchRollToFixedFrame works with a result parameter', function() {
+ it('headingPitchRollToFixedFrame works with a HeadingPitchRoll object and without a result parameter', function() {
var origin = new Cartesian3(1.0, 0.0, 0.0);
var heading = CesiumMath.toRadians(20.0);
var pitch = CesiumMath.toRadians(30.0);
var roll = CesiumMath.toRadians(40.0);
+ var hpr = new HeadingPitchRoll(heading, pitch, roll);
var expectedRotation = Matrix3.fromQuaternion(Quaternion.fromHeadingPitchRoll(heading, pitch, roll));
var expectedX = Matrix3.getColumn(expectedRotation, 0, new Cartesian3());
@@ -282,72 +283,66 @@ defineSuite([
Cartesian3.fromElements(expectedY.z, expectedY.x, expectedY.y, expectedY);
Cartesian3.fromElements(expectedZ.z, expectedZ.x, expectedZ.y, expectedZ);
- var result = new Matrix4();
- var returnedResult = Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll, Ellipsoid.UNIT_SPHERE, result);
+ var returnedResult = Transforms.headingPitchRollToFixedFrame(origin, hpr, Ellipsoid.UNIT_SPHERE);
var actualX = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 0, new Cartesian4()));
var actualY = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 1, new Cartesian4()));
var actualZ = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 2, new Cartesian4()));
var actualTranslation = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 3, new Cartesian4()));
- expect(returnedResult).toBe(result);
expect(actualX).toEqual(expectedX);
expect(actualY).toEqual(expectedY);
expect(actualZ).toEqual(expectedZ);
expect(actualTranslation).toEqual(origin);
});
- it('aircraftHeadingPitchRollToFixedFrame works without a result parameter', function() {
+ it('headingPitchRollToFixedFrame works with a result parameter', function() {
var origin = new Cartesian3(1.0, 0.0, 0.0);
var heading = CesiumMath.toRadians(20.0);
var pitch = CesiumMath.toRadians(30.0);
var roll = CesiumMath.toRadians(40.0);
+ var hpr = new HeadingPitchRoll(heading, pitch, roll);
var expectedRotation = Matrix3.fromQuaternion(Quaternion.fromHeadingPitchRoll(heading, pitch, roll));
var expectedX = Matrix3.getColumn(expectedRotation, 0, new Cartesian3());
var expectedY = Matrix3.getColumn(expectedRotation, 1, new Cartesian3());
var expectedZ = Matrix3.getColumn(expectedRotation, 2, new Cartesian3());
- Cartesian3.fromElements(expectedX.z, -expectedX.y, expectedX.x, expectedX);
- Cartesian3.fromElements(expectedY.z, -expectedY.y, expectedY.x, expectedY);
- Cartesian3.fromElements(expectedZ.z, -expectedZ.y, expectedZ.x, expectedZ);
-
- scratchHeadingPitchRoll.heading = heading;
- scratchHeadingPitchRoll.pitch = pitch;
- scratchHeadingPitchRoll.roll = roll;
+ Cartesian3.fromElements(expectedX.z, expectedX.x, expectedX.y, expectedX);
+ Cartesian3.fromElements(expectedY.z, expectedY.x, expectedY.y, expectedY);
+ Cartesian3.fromElements(expectedZ.z, expectedZ.x, expectedZ.y, expectedZ);
- var returnedResult = Transforms.aircraftHeadingPitchRollToFixedFrame(origin, scratchHeadingPitchRoll, Ellipsoid.UNIT_SPHERE);
+ var result = new Matrix4();
+ var returnedResult = Transforms.headingPitchRollToFixedFrame(origin, hpr, Ellipsoid.UNIT_SPHERE, result);
var actualX = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 0, new Cartesian4()));
var actualY = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 1, new Cartesian4()));
var actualZ = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 2, new Cartesian4()));
var actualTranslation = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 3, new Cartesian4()));
+ expect(returnedResult).toBe(result);
expect(actualX).toEqual(expectedX);
expect(actualY).toEqual(expectedY);
expect(actualZ).toEqual(expectedZ);
expect(actualTranslation).toEqual(origin);
});
- it('aircraftHeadingPitchRollToFixedFrame works with a result parameter', function() {
+ it('headingPitchRollToFixedFrame works with a HeadingPitchRoll object and a result parameter', function() {
var origin = new Cartesian3(1.0, 0.0, 0.0);
var heading = CesiumMath.toRadians(20.0);
var pitch = CesiumMath.toRadians(30.0);
var roll = CesiumMath.toRadians(40.0);
+ var hpr = new HeadingPitchRoll(heading, pitch, roll);
var expectedRotation = Matrix3.fromQuaternion(Quaternion.fromHeadingPitchRoll(heading, pitch, roll));
var expectedX = Matrix3.getColumn(expectedRotation, 0, new Cartesian3());
var expectedY = Matrix3.getColumn(expectedRotation, 1, new Cartesian3());
var expectedZ = Matrix3.getColumn(expectedRotation, 2, new Cartesian3());
- Cartesian3.fromElements(expectedX.z, -expectedX.y, expectedX.x, expectedX);
- Cartesian3.fromElements(expectedY.z, -expectedY.y, expectedY.x, expectedY);
- Cartesian3.fromElements(expectedZ.z, -expectedZ.y, expectedZ.x, expectedZ);
-
- scratchHeadingPitchRoll.heading = heading;
- scratchHeadingPitchRoll.pitch = pitch;
- scratchHeadingPitchRoll.roll = roll;
+ Cartesian3.fromElements(expectedX.z, expectedX.x, expectedX.y, expectedX);
+ Cartesian3.fromElements(expectedY.z, expectedY.x, expectedY.y, expectedY);
+ Cartesian3.fromElements(expectedZ.z, expectedZ.x, expectedZ.y, expectedZ);
var result = new Matrix4();
- var returnedResult = Transforms.aircraftHeadingPitchRollToFixedFrame(origin, scratchHeadingPitchRoll, Ellipsoid.UNIT_SPHERE, result);
+ var returnedResult = Transforms.headingPitchRollToFixedFrame(origin, hpr, Ellipsoid.UNIT_SPHERE, result);
var actualX = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 0, new Cartesian4()));
var actualY = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 1, new Cartesian4()));
var actualZ = Cartesian3.fromCartesian4(Matrix4.getColumn(returnedResult, 2, new Cartesian4()));
@@ -365,8 +360,9 @@ defineSuite([
var heading = CesiumMath.toRadians(20.0);
var pitch = CesiumMath.toRadians(30.0);
var roll = CesiumMath.toRadians(40.0);
+ var hpr = new HeadingPitchRoll(heading, pitch, roll);
- var transform = Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll, Ellipsoid.UNIT_SPHERE);
+ 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);
@@ -374,47 +370,50 @@ defineSuite([
expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON11);
});
- it('headingPitchRollQuaternion works with a result parameter', function() {
+ it('headingPitchRollQuaternion works with a HeadingPitchRoll object and without a result parameter', function() {
var origin = new Cartesian3(1.0, 0.0, 0.0);
var heading = CesiumMath.toRadians(20.0);
var pitch = CesiumMath.toRadians(30.0);
var roll = CesiumMath.toRadians(40.0);
+ var hpr = new HeadingPitchRoll(heading, pitch, roll);
- var transform = Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll, Ellipsoid.UNIT_SPHERE);
+ var transform = Transforms.headingPitchRollToFixedFrame(origin, hpr, Ellipsoid.UNIT_SPHERE);
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);
var actual = Matrix3.fromQuaternion(quaternion);
- expect(quaternion).toBe(result);
expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON11);
});
- it('aircraftHeadingPitchRollQuaternion works without a result parameter', function() {
+ it('headingPitchRollQuaternion works with a result parameter', function() {
var origin = new Cartesian3(1.0, 0.0, 0.0);
- scratchHeadingPitchRoll.heading = CesiumMath.toRadians(20.0);
- scratchHeadingPitchRoll.pitch = CesiumMath.toRadians(30.0);
- scratchHeadingPitchRoll.roll = CesiumMath.toRadians(40.0);
+ var heading = CesiumMath.toRadians(20.0);
+ var pitch = CesiumMath.toRadians(30.0);
+ var roll = CesiumMath.toRadians(40.0);
+ var hpr = new HeadingPitchRoll(heading, pitch, roll);
- var transform = Transforms.aircraftHeadingPitchRollToFixedFrame(origin, scratchHeadingPitchRoll, Ellipsoid.UNIT_SPHERE);
+ var transform = Transforms.headingPitchRollToFixedFrame(origin, hpr, Ellipsoid.UNIT_SPHERE);
var expected = Matrix4.getRotation(transform, new Matrix3());
- var quaternion = Transforms.aircraftHeadingPitchRollQuaternion(origin, scratchHeadingPitchRoll, Ellipsoid.UNIT_SPHERE);
+ var result = new Quaternion();
+ var quaternion = Transforms.headingPitchRollQuaternion(origin, heading, pitch, roll, Ellipsoid.UNIT_SPHERE, result);
var actual = Matrix3.fromQuaternion(quaternion);
+ expect(quaternion).toBe(result);
expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON11);
});
- it('aircraftHeadingPitchRollQuaternion works with a result parameter', function() {
+ it('headingPitchRollQuaternion works with a HeadingPitchRoll object and a result parameter', function() {
var origin = new Cartesian3(1.0, 0.0, 0.0);
- scratchHeadingPitchRoll.heading = CesiumMath.toRadians(20.0);
- scratchHeadingPitchRoll.pitch = CesiumMath.toRadians(30.0);
- scratchHeadingPitchRoll.roll = CesiumMath.toRadians(40.0);
+ var heading = CesiumMath.toRadians(20.0);
+ var pitch = CesiumMath.toRadians(30.0);
+ var roll = CesiumMath.toRadians(40.0);
+ var hpr = new HeadingPitchRoll(heading, pitch, roll);
- var transform = Transforms.aircraftHeadingPitchRollToFixedFrame(origin, scratchHeadingPitchRoll, Ellipsoid.UNIT_SPHERE);
+ var transform = Transforms.headingPitchRollToFixedFrame(origin, hpr, Ellipsoid.UNIT_SPHERE);
var expected = Matrix4.getRotation(transform, new Matrix3());
var result = new Quaternion();
- var quaternion = Transforms.aircraftHeadingPitchRollQuaternion(origin, scratchHeadingPitchRoll, 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);
@@ -862,8 +861,9 @@ 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 modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll, ellipsoid);
+ var modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid);
var modelMatrix2D = Transforms.basisTo2D(projection, modelMatrix, new Matrix4());
var translation2D = Cartesian3.fromCartesian4(Matrix4.getColumn(modelMatrix2D, 3, new Cartesian4()));
@@ -882,8 +882,9 @@ 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 modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, heading, pitch, roll, ellipsoid);
+ var modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid);
var modelMatrix2D = Transforms.basisTo2D(projection, modelMatrix, new Matrix4());
var rotation2D = Matrix4.getRotation(modelMatrix2D, new Matrix3());
@@ -892,11 +893,11 @@ defineSuite([
var enuInverse = Matrix4.inverseTransformation(enu, enu);
var hprPlusTranslate = Matrix4.multiply(enuInverse, modelMatrix, new Matrix4());
- var hpr = Matrix4.getRotation(hprPlusTranslate, new Matrix3());
+ var hpr2 = Matrix4.getRotation(hprPlusTranslate, new Matrix3());
- var row0 = Matrix3.getRow(hpr, 0, new Cartesian3());
- var row1 = Matrix3.getRow(hpr, 1, new Cartesian3());
- var row2 = Matrix3.getRow(hpr, 2, new Cartesian3());
+ var row0 = Matrix3.getRow(hpr2, 0, new Cartesian3());
+ var row1 = Matrix3.getRow(hpr2, 1, new Cartesian3());
+ var row2 = Matrix3.getRow(hpr2, 2, new Cartesian3());
var expected = new Matrix3();
Matrix3.setRow(expected, 0, row2, expected);
@@ -948,30 +949,6 @@ defineSuite([
}).toThrowDeveloperError();
});
- it('aircraftHeadingPitchRollToFixedFrame throws without an origin', function() {
- expect(function() {
- Transforms.aircraftHeadingPitchRollToFixedFrame(undefined, scratchHeadingPitchRoll);
- }).toThrowDeveloperError();
- });
-
- it('aircraftHeadingPitchRollToFixedFrame throws without an headingPitchRoll', function() {
- expect(function() {
- Transforms.aircraftHeadingPitchRollToFixedFrame(Cartesian3.ZERO, undefined);
- }).toThrowDeveloperError();
- });
-
- it('aircraftHeadingPitchRollQuaternion throws without an origin', function() {
- expect(function() {
- Transforms.aircraftHeadingPitchRollQuaternion(undefined, scratchHeadingPitchRoll);
- }).toThrowDeveloperError();
- });
-
- it('aircraftHeadingPitchRollQuaternion throws without an headingPitchRoll', function() {
- expect(function() {
- Transforms.aircraftHeadingPitchRollQuaternion(Cartesian3.ZERO, undefined);
- }).toThrowDeveloperError();
- });
-
it('computeTemeToPseudoFixedMatrix throws without a date', function() {
expect(function() {
Transforms.computeTemeToPseudoFixedMatrix(undefined);
diff --git a/Specs/Scene/ShadowMapSpec.js b/Specs/Scene/ShadowMapSpec.js
index dfd14519819c..692a68548a2f 100644
--- a/Specs/Scene/ShadowMapSpec.js
+++ b/Specs/Scene/ShadowMapSpec.js
@@ -11,6 +11,7 @@ defineSuite([
'Core/EllipsoidTerrainProvider',
'Core/GeometryInstance',
'Core/HeadingPitchRange',
+ 'Core/HeadingPitchRoll',
'Core/HeightmapTerrainData',
'Core/JulianDate',
'Core/Math',
@@ -43,6 +44,7 @@ defineSuite([
EllipsoidTerrainProvider,
GeometryInstance,
HeadingPitchRange,
+ HeadingPitchRoll,
HeightmapTerrainData,
JulianDate,
CesiumMath,
@@ -101,13 +103,13 @@ defineSuite([
sunShadowMap = scene.shadowMap;
var boxOrigin = new Cartesian3.fromRadians(longitude, latitude, boxHeight);
- var boxTransform = Transforms.headingPitchRollToFixedFrame(boxOrigin, 0.0, 0.0, 0.0);
+ var boxTransform = Transforms.headingPitchRollToFixedFrame(boxOrigin, new HeadingPitchRoll());
var floorOrigin = new Cartesian3.fromRadians(longitude, latitude, floorHeight);
- var floorTransform = Transforms.headingPitchRollToFixedFrame(floorOrigin, 0.0, 0.0, 0.0);
+ var floorTransform = Transforms.headingPitchRollToFixedFrame(floorOrigin, new HeadingPitchRoll());
var roomOrigin = new Cartesian3.fromRadians(longitude, latitude, height);
- var roomTransform = Transforms.headingPitchRollToFixedFrame(roomOrigin, 0.0, 0.0, 0.0);
+ var roomTransform = Transforms.headingPitchRollToFixedFrame(roomOrigin, new HeadingPitchRoll());
var modelPromises = [];
modelPromises.push(loadModel({
@@ -661,7 +663,7 @@ defineSuite([
for (var i = 0; i < 6; ++i) {
var box = scene.primitives.add(Model.fromGltf({
url : boxUrl,
- modelMatrix : Transforms.headingPitchRollToFixedFrame(origins[i], 0.0, 0.0, 0.0),
+ modelMatrix : Transforms.headingPitchRollToFixedFrame(origins[i], new HeadingPitchRoll()),
scale : 0.2
}));
scene.render(); // Model is pre-loaded, render one frame to make it ready