Haversine distance between two points, expressed in meters.
    Implemented from http://www.movable-type.co.uk/scripts/latlong.html
774310
def haversine_distance(latitude_1, longitude_1, latitude_2, longitude_2):
    
    d_lat = to_rad(latitude_1 - latitude_2)
    d_lon = to_rad(longitude_1 - longitude_2)
    lat1 = to_rad(latitude_1)
    lat2 = to_rad(latitude_2)

    #pylint: disable=invalid-name
    a = math.sin(d_lat/2) * math.sin(d_lat/2) + \
        math.sin(d_lon/2) * math.sin(d_lon/2) * math.cos(lat1) * math.cos(lat2)
    c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
    d = EARTH_RADIUS * c

    return d
1231945
function distance(from, to) {
  const degrees2radians = Math.PI / 180;
  const dLat = degrees2radians * (to[1] - from[1]);
  const dLon = degrees2radians * (to[0] - from[0]);
  const lat1 = degrees2radians * from[1];
  const lat2 = degrees2radians * to[1];

  const a = Math.pow(Math.sin(dLat / 2), 2) +
        Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
  return Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}
306789
def distance_tt_point(a, b):
    
    return math.sqrt((b.lat-a.lat)**2 + (b.lon-a.lon)**2)
398822
def points_distance(x1, y1, x2, y2)
      Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    end
253305
def distance_between_pts(a=(0.0, 0.0), b=(0.0, 0.0)):
    '''
    '''
    assert isinstance(a, tuple)
    assert isinstance(b, tuple)
    l_pt = len(a)
    assert l_pt > 1
    assert l_pt == len(b)
    for i in a:
        assert isinstance(i, float)
    for i in b:
        assert isinstance(i, float)

    return sqrt(sum([(b[i] - a[i])**2 for i in range(l_pt)]))
510850
def point_line_distance(point, start, end):
    
    if start == end:
        return distance(point, start)
    else:
        un_dist = abs(
            (end.lat-start.lat)*(start.lon-point.lon) - (start.lat-point.lat)*(end.lon-start.lon)
        )
        n_dist = sqrt(
            (end.lat-start.lat)**2 + (end.lon-start.lon)**2
        )
        if n_dist == 0:
            return 0
        else:
            return un_dist / n_dist
171972
def get_h_distance(self, latlonalt1, latlonalt2):
        ''''''
        (lat1, lon1, alt1) = latlonalt1
        (lat2, lon2, alt2) = latlonalt2

        lat1 = radians(lat1)
        lon1 = radians(lon1)
        lat2 = radians(lat2)
        lon2 = radians(lon2)

        dLat = lat2 - lat1
        dLon = lon2 - lon1

        # math as per mavextra.distance_two()
        a = sin(0.5 * dLat)**2 + sin(0.5 * dLon)**2 * cos(lat1) * cos(lat2)
        c = 2.0 * atan2(sqrt(a), sqrt(1.0 - a))
        return 6371 * 1000 * c
1364030
static double distanceSq( Point2D_I32 a , Point2D_I32 b ) {
		double dx = b.x-a.x;
		double dy = b.y-a.y;

		return dx*dx + dy*dy;
	}
825582
def haversine(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
    """"""
    lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])

    # haversine formula
    dlon = lon2 - lon1
    dlat = lat2 - lat1
    calc_a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
    calc_c = 2 * asin(sqrt(calc_a))

    return 6371 * calc_c
4228
def distance(other)
      earth_radius = 6371
      Δlat = radians(other.latitude - latitude)
      Δlong = radians(other.longitude - longitude)
      a = sin(Δlat / 2) * sin(Δlat / 2) +
          cos(radians(latitude)) * cos(radians(other.latitude)) *
          sin(Δlong / 2) * sin(Δlong / 2)
      c = 2 * atan2(√(a), √(1 - a))
      earth_radius * c
    end
1279866
function(lineP1, lineP2, point, radius) {
    var distance =
      Math.abs(
        ((lineP2.y - lineP1.y)*point.x) - ((lineP2.x - lineP1.x)*point.y) + (lineP2.x*lineP1.y) - (lineP2.y*lineP1.x)
      ) /
      Math.sqrt(
        Math.pow(lineP2.y - lineP1.y, 2) + Math.pow(lineP2.x - lineP1.x, 2)
      );
    return distance <= radius;
  }
1186780
def _get_distance(self, pnt1, pnt2):
        """"""
        lat1, lon1 = pnt1
        lat2, lon2 = pnt2
        radius = 6356752  # km
        dlat = math.radians(lat2 - lat1)
        dlon = math.radians(lon2 - lon1)
        a = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1)) \
            * math.cos(math.radians(lat2)) * math.sin(dlon / 2) * math.sin(dlon / 2)
        c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
        d = radius * c
        return d
310430
def distance_to(self, p: Union["Unit", Point2, Point3], bot: "BotAI" = None) -> Union[int, float]:
        
        if bot and isinstance(p, Unit):
            index = bot.distances_tag_dict
            return (bot.unit_distances_dict[index[self.tag]][index[p.tag]]) ** 0.5
        return self.position.distance_to_point2(p.position)
204968
def distance_to(other)
      dlat = to_radians(other.lat - lat)
      dlon = to_radians(other.lng - lng)
      a = Math.sin(dlat / 2) * Math.sin(dlat / 2) +
          Math.cos(to_radians(lat)) * Math.cos(to_radians(other.lat)) *
          Math.sin(dlon / 2) * Math.sin(dlon / 2)
      c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
      6371 * c * 1000
    end
863393
function getCoordDistance($latitude1, $longitude1, $latitude2, $longitude2)
        {
            $earth_radius = 6371;

            $latitude1 = floatval($latitude1);
            $longitude1 = floatval($longitude1);
            $latitude2 = floatval($latitude2);
            $longitude2 = floatval($longitude2);

            $dLat = deg2rad($latitude2 - $latitude1);
            $dLon = deg2rad($longitude2 - $longitude1);

            $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * sin($dLon / 2) * sin($dLon / 2);
            $c = 2 * asin(sqrt($a));
            $d = $earth_radius * $c;

            return $d;

        }
1133138
def _distance_squared(self, p2: "Point2") -> Union[int, float]:
        
        return (self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2
71771
def distance_to(self, point):
        '''
        
        '''
        angle = math.acos(
            sin(self.lat_radians) * sin(point.lat_radians) +
            cos(self.lat_radians) * cos(point.lat_radians) *
            cos(self.long_radians - point.long_radians)
        )
        return angle * EARTH_RADIUS