neumachen
11/20/2014 - 8:29 PM

Calculate new coordinates with distance and an angle from a given coordinates.

Calculate new coordinates with distance and an angle from a given coordinates.

public LatLng translateCoordinates(final double distance, final LatLng origpoint, final double angle) {
        final double distanceNorth = Math.sin(angle) * distance;
        final double distanceEast = Math.cos(angle) * distance;
 
        final double earthRadius = 6371000;
 
        final double newLat = origpoint.latitude + (distanceNorth / earthRadius) * 180 / Math.PI;
        final double newLon = origpoint.longitude + (distanceEast / (earthRadius * Math.cos(newLat * 180 / Math.PI))) * 180 / Math.PI;
 
        return new LatLng(newLat, newLon);
}