-
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
Fixed frame converter #4896
Fixed frame converter #4896
Conversation
@kaktus40 could you also please update CHANGES.md and resize the new images in the |
@pjcozzi :it's done |
Hello, after playing with LocalToFixedFrame gallery example, I fear there is another misconception in Cesium. Indeed, heading value is the rotation angle around the third axis (for example in East North Up local reference frame, it's the rotation angle around "Up"). As the reference frame is direct, a positive value of heading means a rotation from first axis (respectively east) to second axis (respectively north) in the plane generated by first and second axis, see here. In LocalToFixedFrame gallery example when you turn heading positively, we should expect that the model turns from east to north in ENU representation but it's the opposite. After checking the code I found this: I don't understand why it's -heading that is used and not simply heading. It's the same remark for pitch here |
Hello, any news for this PR? |
Sorry we haven't had a chance to look at this yet @kaktus40. We might have a chance to at the bug bash this week |
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.
Looks good. Thanks @kaktus40!
Does anyone else want to review this?
CHANGES.md
Outdated
@@ -5,6 +5,12 @@ Change Log | |||
|
|||
* 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`. | |||
* The function `createBinormalAndBitangent` of `GeometryPipeline` will be removed in 1.31. Use the function `createTangentAndBitangent` instead. [#4856](https://github.com/AnalyticalGraphicsInc/cesium/pull/4856) |
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.
You have a couple duplicates here.
@@ -184,17 +188,29 @@ define([ | |||
* @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. | |||
*/ | |||
Quaternion.fromHeadingPitchRoll = function(heading, pitch, roll, result) { | |||
Quaternion.fromHeadingPitchRoll = function(headingOrHeadingPitchRoll, pitchOrResult, roll, 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.
Use an options parameter here.
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.
When you replace the usage throughout the code, create a scratch object literal to avoid many allocations and garbage collection.
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.
Ah I see the deprecation below. Can you add the deprecation to CHANGES.md
? Also, move the deprecation warning into the if-block so the warning only occurs when called with heading, pitch and roll arguments.
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.
I don't see how to use options parameter in Quaternion.fromHeadingPitchRoll as the first parameter will be a HeadingPitchRoll object?
You suggest that rollQuaternion, pitchQuaternion and headingQuaternion become scratch variables? Ok for me but just for information that was the previous design.
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.
This looks good. I didn't realize when I made the first comment that it was deprecating those parameters.
Source/Core/Transforms.js
Outdated
result[15] = 1.0; | ||
return result; | ||
if (!defined(result)) { | ||
result = new Matrix4(); |
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.
Whitespace. Each indent is 4 spaces.
Source/Core/Transforms.js
Outdated
throw new DeveloperError('firstAxis and secondAxis must be east, north, up, west, south or down.'); | ||
} | ||
var thirdAxis = vectorProductLocalFrame[firstAxis][secondAxis]; | ||
var calculateCartesian = { |
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.
These can be file scope scratches.
Source/Core/Transforms.js
Outdated
* @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. | ||
*/ | ||
var resultat= function(origin, ellipsoid, 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.
Would it be better to generate these on load? If not, cache the functions.
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.
Sorry I don't see what you mean :-(
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.
This function will be generated each time localFrameToFixedFrameGenerator
is called. So every call like: Cesium.Transforms.localFrameToFixedFrameGenerator('north','west')
will generate a new function but it doesn't change. Create a file scope object like localFrameToFixedFrameCache
with unique names based on the axis. First you check if the function is in the cache, if it is, return it; if not, generate it and place it in the cache before returning it.
Source/Core/Transforms.js
Outdated
var pitch = headingPitchRoll.pitch; | ||
var roll = headingPitchRoll.roll; | ||
Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, ellipsoid, fixedFrameTransformOrResult, result) { | ||
Check.typeOf.object( 'HeadingPitchRoll', 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.
This should go inside the pragmas to be removed from release builds.
Source/Core/Transforms.js
Outdated
|
||
// checks for required parameters happen in the called functions | ||
var hprQuaternion = Quaternion.fromHeadingPitchRoll(heading, pitch, roll, scratchHPRQuaternion); | ||
deprecationWarning('Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, result)', 'The method was deprecated in Cesium 1.31 and will be removed in version 1.32. ' + |
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.
Same comment.
Source/Core/Transforms.js
Outdated
// checks for required parameters happen in the called functions | ||
Check.typeOf.object('headingPitchRoll', headingPitchRoll); | ||
var transform = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, scratchENUMatrix4); | ||
Check.typeOf.object( 'HeadingPitchRoll', 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.
Same comments.
Source/Scene/Camera.js
Outdated
@@ -1160,14 +1164,16 @@ define([ | |||
var pitch = defaultValue(orientation.pitch, -CesiumMath.PI_OVER_TWO); | |||
var roll = defaultValue(orientation.roll, 0.0); | |||
|
|||
var hpr = new HeadingPitchRoll(heading, pitch, roll); |
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.
Create a scratch variable.
Specs/Core/QuaternionSpec.js
Outdated
@@ -652,7 +660,7 @@ defineSuite([ | |||
Quaternion.fromRotationMatrix(undefined); | |||
}).toThrowDeveloperError(); | |||
}); | |||
|
|||
/* |
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.
Did you mean to leave these commented out?
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.
As fromHeadingPitchRoll use now a headingPitchRoll class, the commented tests have no interest.
Ok I corrected the code in compliance with the review code |
Source/Core/Quaternion.js
Outdated
Check.typeOf.number('pitch', pitch); | ||
Check.typeOf.number('roll', roll); | ||
if (headingOrHeadingPitchRoll instanceof HeadingPitchRoll) { | ||
Check.typeOf.object('headingPitchRoll',headingOrHeadingPitchRoll ); |
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.
There are still whitespace issues. Four spaces should be used for each indent. Please update throughout.
I made the corrections |
Thanks @kaktus40! |
In continuity of #4498 and in response for #3256 , I implemented an ability to express a rotation around a local frame different of ENU.