-
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
adding method to convert heading pitch roll in quaternion defined in … #4048
Merged
pjcozzi
merged 3 commits into
CesiumGS:master
from
kaktus40:adding_AircraftTransformations
Jun 28, 2016
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
f985545
adding method to convert heading pitch roll in quaternion defined in …
kaktus40 1a99619
update tests following recommandations + update of CHANGES.md in orde…
kaktus40 00cdda8
Merge remote-tracking branch 'upstream/master' into adding_AircraftTr…
kaktus40 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,6 +381,36 @@ 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 {Number} heading The heading angle in radians. | ||
* @param {Number} pitch The pitch angle in radians. | ||
* @param {Number} roll The roll angle in radians. | ||
* @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 heading = -Cesium.Math.PI_OVER_TWO; | ||
* var pitch = Cesium.Math.PI_OVER_FOUR; | ||
* var roll = 0.0; | ||
* var transform = Cesium.Transforms.aircraftHeadingPitchRollToFixedFrame(center, heading, pitch, roll); | ||
*/ | ||
Transforms.aircraftHeadingPitchRollToFixedFrame = function(origin, heading, pitch, roll, ellipsoid, result) { | ||
// 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.northEastDownToFixedFrame(origin, ellipsoid, result); | ||
return Matrix4.multiply(result, hprMatrix, result); | ||
}; | ||
|
||
var scratchENUMatrix4 = new Matrix4(); | ||
var scratchHPRMatrix3 = new Matrix3(); | ||
|
||
|
@@ -413,6 +443,35 @@ define([ | |
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 {Number} heading The heading angle in radians. | ||
* @param {Number} pitch The pitch angle in radians. | ||
* @param {Number} roll The roll angle in radians. | ||
* @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 heading = -Cesium.Math.PI_OVER_TWO; | ||
* var pitch = Cesium.Math.PI_OVER_FOUR; | ||
* var roll = 0.0; | ||
* var quaternion = Cesium.Transforms.aircraftHeadingPitchRollQuaternion(center, heading, pitch, roll); | ||
*/ | ||
Transforms.aircraftHeadingPitchRollQuaternion = function(origin, heading, pitch, roll, ellipsoid, result) { | ||
// checks for required parameters happen in the called functions | ||
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. Same comment. |
||
var transform = Transforms.aircraftHeadingPitchRollToFixedFrame(origin, heading, pitch, roll, ellipsoid, scratchENUMatrix4); | ||
var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3); | ||
return Quaternion.fromRotationMatrix(rotation, result); | ||
}; | ||
|
||
|
||
var gmstConstant0 = 6 * 3600 + 41 * 60 + 50.54841; | ||
var gmstConstant1 = 8640184.812866; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you still add unit tests for these with
toThrowDeveloperError
?