Java Distance Calculate distanceInRadians(double latitude1, double longitude1, double latitude2, double longitude2)

Here you can find the source of distanceInRadians(double latitude1, double longitude1, double latitude2, double longitude2)

Description

distance In Radians

License

Open Source License

Parameter

Parameter Description
latitude1 a parameter
longitude1 a parameter
latitude2 a parameter
longitude2 a parameter

Declaration

private static double distanceInRadians(double latitude1, double longitude1, double latitude2,
        double longitude2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  ww w  .  j  av a  2  s. c o m
     * @param latitude1
     * @param longitude1
     * @param latitude2
     * @param longitude2
     * @return
     */
    private static double distanceInRadians(double latitude1, double longitude1, double latitude2,
            double longitude2) {

        double x1 = Math.toRadians(latitude1);
        double y1 = Math.toRadians(longitude1);
        double x2 = Math.toRadians(latitude2);
        double y2 = Math.toRadians(longitude2);

        // great circle distance in radians
        return Math.acos(Math.sin(x1) * Math.sin(x2) + Math.cos(x1) * Math.cos(x2) * Math.cos(y1 - y2));
    }
}

Related

  1. distanceInf(double[] p1, double[] p2)
  2. distanceInMeters(double lat1, double lon1, double lat2, double lon2)
  3. distanceInMetersBetween(final double lat1, final double lng1, final double lat2, final double lng2)
  4. distanceInMilesBetween(float lat1, float lng1, float lat2, float lng2)
  5. distanceInMilesBetweenDouble(Float centerLat, Float centerLon, double lat, double lon)
  6. distanceKM(double lat1, double lng1, double lat2, double lng2)
  7. distanceLevenshtein(CharSequence s, CharSequence t)
  8. distanceLongitude(double latitude, double east, double west)
  9. distanceMat(double[][] m1, double[][] m2)