computeHeading static method
Returns the heading from one Point to another Point. Headings are expressed in degrees clockwise from North within the range [-180,180).
Returns The heading in degrees clockwise from north.
Implementation
static double computeHeading(Point<double> from, Point<double> to) {
// http://williams.best.vwh.net/avform.htm#Crs
final fromLat = toRadians(from.x);
final fromLng = toRadians(from.y);
final toLat = toRadians(to.x);
final toLng = toRadians(to.y);
final dLng = toLng - fromLng;
final heading = atan2(sin(dLng) * cos(toLat),
cos(fromLat) * sin(toLat) - sin(fromLat) * cos(toLat) * cos(dLng));
return MathUtils.wrap(toDegrees(heading), -180, 180);
}