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

More robust negativePiToPi, zeroToTwoPi, and mod #9354

Merged
merged 2 commits into from
Feb 1, 2021
Merged

Conversation

IanLilleyT
Copy link
Contributor

@IanLilleyT IanLilleyT commented Jan 30, 2021

CesiumMath.negativePiToPi, CesiumMath.zeroToTwoPi, and CesiumMath.mod were applying extra math to values that were already in the valid range, causing floating point error.

For example:

console.log(0.1);
>>> 0.1
console.log(Cesium.Math.mod(0.1, 1.0));
>>> 0.10000000000000009

Ultimately the floating point error occurs in: ((m % n) + n) % n inside CesiumMath.mod.

The fix was to early-out if the input was already in the correct range.

Fixes #9312

@cesium-concierge
Copy link

Thanks for the pull request @IanLilleyT!

  • ✔️ Signed CLA found.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@lilleyse
Copy link
Contributor

lilleyse commented Feb 1, 2021

Thanks @IanLilleyT

As an extra precaution I confirmed that other tools give the same mod results for the negative number cases in MathSpec.

Unit tests pass locally and confirmed this fixes #9312

@lilleyse lilleyse merged commit 90db2f5 into master Feb 1, 2021
@lilleyse lilleyse deleted the lessErrorPi branch February 1, 2021 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using certain rectangle of ImageryProvider will cause Cesium stop rendering
3 participants