I was looking over how Cesium calculates Geodetic Latitude (surface normal.) Well actually latitude is just one aspect this function determines, I don’t see a function that just determines GD latitude.
Ellipsoid.prototype.cartesianToCartographic
var p = this.scaleToGeodeticSurface(cartesian, cartesianToCartographicP);
calls Ellipsoid.prototype.scaleToGeodeticSurface
var n = this.geodeticSurfaceNormal(p, cartesianToCartographicN);
calls Ellipsoid.prototype.geodeticSurfaceNormal
Ellipsoid.prototype.geodeticSurfaceNormal
Is pretty basic: (positionX/radiiX^2 , positionY/radiiY^2, positionZ/radiiZ^2)
However Ellipsoid.prototype.scaleToGeodeticSurface is not so straight forward. It seems to go through a loop starting with an approximation till an epsilon threshold is passed.
Well I was trying out another method to obtain the surface normal at any height from the surface. It’s quite simple really and the results are surprisingly close to what Cesium currently calculates. In fact it’s exactly what Cesium calculates at height 0.
What I do is determine the foci points for the ellipse cross-section for the point being measured.
I create 2 vectors:
-1 going through the far foci point and the camera position
-1 going through the near foci point and the camera position
The average pitch of these 2 vectors is the surface normal pitch for that camera position.
It’s exact at height 0. At height 6 million meters the biggest difference from what Cesium calculates is 0.048 deg at 45 deg latitude. But which is accurate?
I was reading this site
I noticed this quote
“For any ellipse’s point the normal to the ellipse at this point bisects the angle between the straight lines drawn from the ellipse foci to the point.”
If you look at the image by that quote you’ll notice it’s indicating the same thing.
Perhaps this holds true even for points away from the surface? One could test by placing the camera on the surface, determine the normal, extend the camera 6 million meters in the direction the normal, then calculate both ways and see what results.
There may be an easier method to determine height as well, but I have not tested it yet.