destinationPoint static method

ILatLong destinationPoint(
  1. ILatLong start,
  2. double distance,
  3. double bearing
)

Returns the destination point from this point having travelled the given distance on the given initial bearing (bearing normally varies around path followed).

@param start the start point @param distance the distance travelled, in same units as earth radius (default: meters) @param bearing the initial bearing in degrees from north @return the destination point @see latlon.js

Implementation

static ILatLong destinationPoint(ILatLong start, double distance, double bearing) {
  double theta = degToRadian(bearing);
  double delta = distance / EQUATORIAL_RADIUS; // angular distance in radians

  double phi1 = degToRadian(start.latitude);
  double lambda1 = degToRadian(start.longitude);

  double phi2 = asin(sin(phi1) * cos(delta) + cos(phi1) * sin(delta) * cos(theta));
  double lambda2 = lambda1 + atan2(sin(theta) * sin(delta) * cos(phi1), cos(delta) - sin(phi1) * sin(phi2));

  return new LatLong(radianToDeg(phi2), radianToDeg(lambda2));
}