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

Cartographic.fromCartesian returns wrong results if the cartesian is not on the ellipsoid surface #4611

Closed
duvifn opened this issue Nov 6, 2016 · 0 comments · Fixed by #4612

Comments

@duvifn
Copy link
Contributor

duvifn commented Nov 6, 2016

Hi,
I recently used Cartographic.fromCartesian method and got wrong results.
In order to see the problem please run the following code.
Currently it's logs 'false' to the console.

var cartographic1 = Cesium.Cartographic.fromDegrees(35.766989, 33.333602, 3000);
var cartesian1 = Cesium.Cartesian3.fromRadians(cartographic1.longitude, cartographic1.latitude, cartographic1.height);
var cartographic2 = Cesium.Cartographic.fromCartesian(cartesian1);

console.log(cartographic1.equalsEpsilon(cartographic2,Cesium.Math.EPSILON8)); //false

(Sandcastle)

I have noticed that Ellipsoid.cartesianToCartographic produces an accurate result in this case.
It seems that Cartographic.fromCartesian is a copy of Ellipsoid.cartesianToCartographic (it was probably cloned because requirejs doesn't properly handle circular dependencies).
However there is a typo in the Cartographic.fromCartesian version.

I fixed this typo and added two additional tests.

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 a pull request may close this issue.

1 participant