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

Fixed frame converter #4896

Merged
merged 22 commits into from
Feb 10, 2017
Merged

Fixed frame converter #4896

merged 22 commits into from
Feb 10, 2017

Conversation

kaktus40
Copy link
Contributor

In continuity of #4498 and in response for #3256 , I implemented an ability to express a rotation around a local frame different of ENU.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 21, 2017

Thanks for this big contribution, @kaktus40!

@bagnell could you please review this?

@xtassin @speigg your input here is also very much appreciated.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 21, 2017

@kaktus40 could you also please update CHANGES.md and resize the new images in the Apps/Sandcastle/gallery/ directory to be the same as the other Sandcastle thumbnails?

@kaktus40
Copy link
Contributor Author

@pjcozzi :it's done

@kaktus40
Copy link
Contributor Author

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

@kaktus40
Copy link
Contributor Author

kaktus40 commented Feb 5, 2017

Hello, any news for this PR?

@hpinkos
Copy link
Contributor

hpinkos commented Feb 6, 2017

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

Copy link
Contributor

@bagnell bagnell left a 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)
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

result[15] = 1.0;
return result;
if (!defined(result)) {
result = new Matrix4();
Copy link
Contributor

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.

throw new DeveloperError('firstAxis and secondAxis must be east, north, up, west, south or down.');
}
var thirdAxis = vectorProductLocalFrame[firstAxis][secondAxis];
var calculateCartesian = {
Copy link
Contributor

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.

* @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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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 :-(

Copy link
Contributor

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.

var pitch = headingPitchRoll.pitch;
var roll = headingPitchRoll.roll;
Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, ellipsoid, fixedFrameTransformOrResult, result) {
Check.typeOf.object( 'HeadingPitchRoll', headingPitchRoll);
Copy link
Contributor

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.


// 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. ' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.

// 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments.

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a scratch variable.

@@ -652,7 +660,7 @@ defineSuite([
Quaternion.fromRotationMatrix(undefined);
}).toThrowDeveloperError();
});

/*
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@pjcozzi
Copy link
Contributor

pjcozzi commented Feb 8, 2017

Does anyone else want to review this?

Just @bagnell's review is OK with me.

@kaktus40 if you are able to update this tomorrow or Friday morning, it will likely get merged quickly since we are having a bug bash and focused on merging PRs.

Thanks again for this!

@kaktus40
Copy link
Contributor Author

kaktus40 commented Feb 8, 2017

Ok I corrected the code in compliance with the review code

Check.typeOf.number('pitch', pitch);
Check.typeOf.number('roll', roll);
if (headingOrHeadingPitchRoll instanceof HeadingPitchRoll) {
Check.typeOf.object('headingPitchRoll',headingOrHeadingPitchRoll );
Copy link
Contributor

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.

@kaktus40
Copy link
Contributor Author

kaktus40 commented Feb 9, 2017

I made the corrections

@bagnell
Copy link
Contributor

bagnell commented Feb 10, 2017

Thanks @kaktus40!

@bagnell bagnell merged commit 03bc20f into CesiumGS:master Feb 10, 2017
@kaktus40 kaktus40 deleted the fixedFrameConverter branch February 12, 2017 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants