class Geo {

    public static double bearing(double lat1, double lon1, double lat2, double lon2) {
        final double lat1r = Math.toRadians(lat1);
        final double lat2r = Math.toRadians(lat2);
        final double delta_lon = Math.toRadians(lon2 - lon1);
        final double y = Math.sin(delta_lon) * Math.cos(lat2r);
        final double x = Math.cos(lat1r) * Math.sin(lat2r) - Math.sin(lat1r) * Math.cos(lat2r) * Math.cos(delta_lon);
        return Math.toDegrees(Math.atan2(y, x));
    }

}