Geo { @NonNull public static LatLng moveDirection(double latitude, double longitude, double bearing, double distance) { final double d = distance / R; final double lat = Math.toRadians(latitude); final double lon = Math.toRadians(longitude); final double bear = Math.toRadians(bearing); final double sin_d = Math.sin(d); final double cos_d = Math.cos(d); final double sin_lat = Math.sin(lat); final double cos_lat = Math.cos(lat); final double sin_d_cos_lat = sin_d * cos_lat; final double lat2 = Math.asin(sin_lat * cos_d + sin_d_cos_lat * Math.cos(bear)); final double lon2 = lon + Math.atan2(Math.sin(bear) * sin_d_cos_lat, cos_d - sin_lat * Math.sin(lat2)); final double lat3 = Math.toDegrees(lat2); final double lon3 = mod360(Math.toDegrees(lon2)); return new LatLng(lat3, lon3); }  static double distance(double lat1, double lon1, double lat2, double lon2); static double fastDistance(double lat1, double lon1, double lat2, double lon2); static double bearing(double lat1, double lon1, double lat2, double lon2); @NonNull static LatLng moveDirection(double latitude, double longitude, double bearing, double distance);  }
@Test public void moveDirection() { final LatLng moved = Geo.moveDirection(seattle.latitude, seattle.longitude, bearing, distance); assertEquals(la.latitude, moved.latitude, 0.01); assertEquals(la.longitude, moved.longitude, 0.01); }