[GIS] Formula for the great circle arc between two points (lng/lat coordinates)

great circleinterpolationorigin-destination

I am trying to animate a point moving from one location to another on a map. And I would like the point to travel along the great circle arc between the locations, rather than in a straight line.

Given the starting coordinates (lng/lat) and the ending coordinates, is there a formula for interpolating along the great circle arc to get the point's coordinates at each step in its route.

I need to run this calculation on the fly (in a WebGL shader), so I can't use PostGIS or a GIS application. It needs to be a formula or algorithm.

Best Answer

You can use GeographicLib, which has bindings to several programming languages. For example, the JavaScript version has an example to compute waypoints between two points.

Essentially, you create an inverse geodesic line between the two locations, then generate as many points (either total number or interval distance) between the two points along the geodesic line.