Here you can find the source of distanceInRadians(double latitude1, double longitude1, double latitude2, double longitude2)
Parameter | Description |
---|---|
latitude1 | a parameter |
longitude1 | a parameter |
latitude2 | a parameter |
longitude2 | a parameter |
private static double distanceInRadians(double latitude1, double longitude1, double latitude2, double longitude2)
//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)); } }