Returns bearing from (lat1, lon1) to (lat2, lon2) in degrees
@param lat1
@param lon1
@param lat2
@param lon2
@return
71
public static final double bearing(double lat1, double lon1, double lat2, double lon2)
    {
        return Math.toDegrees(radBearing(lat1, lon1, lat2, lon2));
    }
151254
def separation_cos_angle(lon0, lat0, lon1, lat1):
    """"""
    return (np.sin(lat1) * np.sin(lat0) + np.cos(lat1) * np.cos(lat0) *
            np.cos(lon1 - lon0))
1355141
public final double getDistanceKmToPath(Position p1, Position p2) {
		double d = radiusEarthKm
				* asin(sin(getDistanceToKm(p1) / radiusEarthKm)
						* sin(toRadians(getBearingDegrees(p1)
								- p1.getBearingDegrees(p2))));
		return abs(d);
	}
780899
public double distance(Double lat, Double lon) {
		return calculateDistance(latitude, longitude, lat, lon);
	}
289003
public DoublePoint Divide(DoublePoint point1, DoublePoint point2) {
        DoublePoint result = new DoublePoint(point1);
        result.Divide(point2);
        return result;
    }
446863
public static final double departure(double latitude1, double latitude2)
    {
        checkLatitude(latitude1);
        checkLatitude(latitude2);
        return departure((latitude1+latitude2)/2);
    }
867986
public static function getDistance(Point $point1, Point $point2)
	{
		$latFrom = deg2rad($point1->latitude);
		$lonFrom = deg2rad($point1->longitude);
		$latTo = deg2rad($point2->latitude);
		$lonTo = deg2rad($point2->longitude);

		$lonDelta = $lonTo - $lonFrom;
		$a = pow(cos($latTo) * sin($lonDelta), 2) + pow(cos($latFrom) * sin($latTo) - sin($latFrom) * cos($latTo) * cos($lonDelta), 2);
		$b = sin($latFrom) * sin($latTo) + cos($latFrom) * cos($latTo) * cos($lonDelta);
		$angle = atan2(sqrt($a), $b);

		return $angle * self::EARTH_RADIUS;
	}
1128682
public DoublePoint Multiply(DoublePoint point1, DoublePoint point2) {
        DoublePoint result = new DoublePoint(point1);
        result.Multiply(point2);
        return result;
    }
276917
def distance(latitude_1, longitude_1, elevation_1, latitude_2, longitude_2, elevation_2,
             haversine=None):
    

    # If points too distant -- compute haversine distance:
    if haversine or (abs(latitude_1 - latitude_2) > .2 or abs(longitude_1 - longitude_2) > .2):
        return haversine_distance(latitude_1, longitude_1, latitude_2, longitude_2)

    coef = math.cos(latitude_1 / 180. * math.pi)
    #pylint: disable=invalid-name
    x = latitude_1 - latitude_2
    y = (longitude_1 - longitude_2) * coef

    distance_2d = math.sqrt(x * x + y * y) * ONE_DEGREE

    if elevation_1 is None or elevation_2 is None or elevation_1 == elevation_2:
        return distance_2d

    return math.sqrt(distance_2d ** 2 + (elevation_1 - elevation_2) ** 2)
1194820
function geoGetDistance($lat1,$lon1,$lat2,$lon2,$unit='M') {
        
      // calculate miles
      $M =  69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($lon1 - $lon2)))); 

      switch(strtoupper($unit))
      {
        case 'K':
          // kilometers
          return $M * 1.609344;
          break;
        case 'N':
          // nautical miles
          return $M * 0.868976242;
          break;
        case 'F':
          // feet
          return $M * 5280;
          break;            
        case 'I':
          // inches
          return $M * 63360;
          break;            
        case 'M':
        default:
          // miles
          return $M;
          break;
      }
      
    }
958271
public DoublePoint Subtract(DoublePoint point1, DoublePoint point2) {
        DoublePoint result = new DoublePoint(point1);
        result.Subtract(point2);
        return result;
    }
25924
public static function getDistance($lat1, $long1, $lat2, $long2) {
        return self::distanceFactory($lat1, $long1, $lat2, $long2)->get();
    }
646091
public function getDistance($geo1, $geo2)
    {
        try {
            $lat1 = $geo1['lat'];
            $lng1 = $geo1['lng'];
            $lat2 = $geo2['lat'];
            $lng2 = $geo2['lng'];

            $earthRadius = 6367000; //approximate radius of earth in meters

            $lat1 = ($lat1 * pi() ) / 180;
            $lng1 = ($lng1 * pi() ) / 180;

            $lat2 = ($lat2 * pi() ) / 180;
            $lng2 = ($lng2 * pi() ) / 180;

            $calcLongitude = $lng2 - $lng1;
            $calcLatitude = $lat2 - $lat1;
            $stepOne = pow(sin($calcLatitude / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($calcLongitude / 2), 2);
            $stepTwo = 2 * asin(min(1, sqrt($stepOne)));
            $calculatedDistance = $earthRadius * $stepTwo;

            return round($calculatedDistance);
        } catch (Exception $e) {
            throw $e;
        }
    }
173362
def lonlat2xyz(lon, lat):
    

    lons = np.array(lon)
    lats = np.array(lat)

    xs = np.cos(lats) * np.cos(lons)
    ys = np.cos(lats) * np.sin(lons)
    zs = np.sin(lats)

    return xs, ys, zs
1009239
public static double bearingDegDeg(double latS, double lngS, double latE, double lngE) {
    return rad2deg(bearingRad(deg2rad(latS), deg2rad(lngS), deg2rad(latE), deg2rad(lngE)));
  }
72964
public double normalizedDistance(double[] point1, double[] point2) throws Exception {
    return Math.sqrt(distance2(point1, point2)) / point1.length;
  }
484986
public static double giveAngle(IAtom from, IAtom to1, IAtom to2) {
        return (giveAngleBothMethods(from, to1, to2, true));
    }