direction method
Calculate the direction between tow points.
target
: Target geoData.
Implementation
double direction(GeoData target) {
final y2 = pi * target.longitude / 180.0;
final y1 = pi * longitude / 180.0;
final x2 = pi * target.latitude / 180.0;
final x1 = pi * latitude / 180.0;
final w = 180 *
atan2(
sin(x2 - x1),
cos(y1) * tan(y2) - sin(y1) * cos(x2 - x1),
) /
pi;
return w - 90;
}