I know the title is a little confusing, I will try to express it clear below.
While I was trying to get the altitude of a click position, I found two working snippet that both get me the altitude. However, there is slightly different between the two results.
Below are the snippet I used to get the value.
## Snippet 1
var ellipsoid = viewer.scene.globe.ellipsoid; var pickedObject = viewer.scene.pick(click.position);
var cartesian = viewer.camera.pickEllipsoid(click.position, ellipsoid); var cartographic = ellipsoid.cartesianToCartographic(cartesian);
var longitudeString = Cesium.Math.toDegrees(cartographic.longitude);
var latitudeString = Cesium.Math.toDegrees(cartographic.latitude);
## Snippet 2
var ray = viewer.camera.getPickRay(click.position);
var cartesian = viewer.scene.globe.pick(ray, viewer.scene);
var cartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(cartesian);
var long2 = Cesium.Math.toDegrees(cartographic.longitude);
var lat2 = Cesium.Math.toDegrees(cartographic.latitude);
However, after applied these two on the same click position, the coordinates I got are slightly different, which caused the altitudes are different. Can anybody explain to me a little bit about this difference?