-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Tidy up HeadingPitchRoll API #4498
Changes from 6 commits
8b72bf8
35bb5cc
c58317c
b9b0669
f20531d
718e41a
5eec6a0
9124171
3c799c5
09bfcb6
9544f6a
7bff93f
d022981
51c011b
e0319eb
f20b28a
72d40d4
33a8b41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ define([ | |
'./Cartographic', | ||
'./defaultValue', | ||
'./defined', | ||
'./deprecationWarning', | ||
'./DeveloperError', | ||
'./EarthOrientationParameters', | ||
'./EarthOrientationParametersSample', | ||
|
@@ -28,6 +29,7 @@ define([ | |
Cartographic, | ||
defaultValue, | ||
defined, | ||
deprecationWarning, | ||
DeveloperError, | ||
EarthOrientationParameters, | ||
EarthOrientationParametersSample, | ||
|
@@ -456,10 +458,12 @@ define([ | |
* 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. | ||
* | ||
* You should pass a HeadingPitchRoll object. Passing separate heading, pitch, and roll values is deprecated. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
* | ||
* @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|Number} hprOrHeading A HeadingPitchRoll or the heading angle in radians. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document as just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
* @param {Number?} pitch The pitch angle in radians if a HeadingPitchRoll object was not passed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry if I wasn't clear, let's also remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Confirmed that the generated documentation is as desired: Cesium.Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, result) → Matrix4 |
||
* @param {Number?} roll The roll angle in radians if a HeadingPitchRoll object was not passed. | ||
* @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,51 +476,26 @@ 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, hprOrHeading, pitch, roll, ellipsoid, result) { | ||
var heading; | ||
if (typeof hprOrHeading === 'object') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
// Shift arguments using assignments to encourage JIT optimization. | ||
ellipsoid = pitch; | ||
result = roll; | ||
heading = hprOrHeading.heading; | ||
pitch = hprOrHeading.pitch; | ||
roll = hprOrHeading.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.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Submit an issue to remove this deprecated feature. |
||
heading = hprOrHeading; | ||
} | ||
// 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); | ||
}; | ||
|
||
/** | ||
* 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 scratchENUMatrix4 = new Matrix4(); | ||
var scratchHPRMatrix3 = new Matrix3(); | ||
|
||
|
@@ -574,7 +553,7 @@ define([ | |
*/ | ||
Transforms.aircraftHeadingPitchRollQuaternion = function(origin, headingPitchRoll, ellipsoid, result) { | ||
// checks for required parameters happen in the called functions | ||
var transform = Transforms.aircraftHeadingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, scratchENUMatrix4); | ||
var transform = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, scratchENUMatrix4); | ||
var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3); | ||
return Quaternion.fromRotationMatrix(rotation, result); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
0.0, 0.0, 0.0
is the default, can you change this throughout to justnew HeadingPitchRoll ();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.