Finding a point on the surface at a given distance

I had a problem where given two points: an origin and a direction, I needed to find a 3rd point at a given distance away from the origin point. I needed to use the distance along the earth surface when calculating the destination point. No tunneling through the earth or flying above it.

Cesium already has an easy way to do this with the EllipsoidGeodesic class. In my case I just needed to provide it the origin and direction points. Then I could use the interpolateUsingSurfaceDistance function to find the point at a given distance.

See the Sandcastle demo.

1 Like

I didn’t really study the code, but it seems to work after changing (on line 39) -distance to distance. (found out the function does measure along an oblate ellipsoid)

Thanks for pointing out that bug. I updated the sandcastle link with the fix and it works better now!

1 Like

Neat program!
If you make distance 40075000 and make a line along the equator the red dot lands on the green dot.
If you make distance 40007800 and make a line along a merdian the red dot lands on the green dot.
67200 meter difference between the equator and meridian great circles, a 0.16% difference.