Computes the distance from this postcode to another postcode using the
 Haversine formula

 @return [Float]
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
881891
def distance
      return nil unless @locations.size > 1
      locations.each_cons(2).reduce(0) do |acc, (loc1, loc2)|
        acc + loc1.distance_to(loc2)
      end
    end
736869
public static float distanceSq( float[] a , float[]b ) {
		float ret = 0;
		for( int i = 0; i < a.length; i++ ) {
			float d = a[i] - b[i];
			ret += d*d;
		}
		return ret;
	}
715182
def distance(p1, p2):
    '''
    '''
    return sum((a - b) ** 2 for a, b in zip(p1, p2)) ** 0.5
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
432318
private static final double getEnd2EndDistance(Atom[] ca1, Atom[] ca2, int p1b, int p1e, int p2b, int p2e)
	{

		double min = 99;
			double dist1 = Calc.getDistance(ca1[p1b], ca1[p1e]);
			double dist2 = Calc.getDistance(ca2[p2b], ca2[p2e]);
			min = dist1 - dist2;

		return Math.abs(min);
	}
998491
def distance_to_point2(self, p2: "Point2") -> Union[int, float]:
        
        return ((self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2) ** 0.5
779318
def Distance(lat1, lon1, lat2, lon2):
    """"""

    az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2)
    return az21, dist
1048504
def distance(self, other):
        """"""
        return math.acos(self._pos3d.dot(other.vector))
1365462
public static double distance(DLocation p1, DLocation p2) {
		double p1lat = Math.toRadians(p1.getLatitude());
		double p1lon = Math.toRadians(p1.getLongitude());
		double p2lat = Math.toRadians(p2.getLatitude());
		double p2lon = Math.toRadians(p2.getLongitude());
		return distance(p1lat, p1lon, p2lat, p2lon);
	}
699883
def distance_to_furthest(self, ps: Union["Units", List["Point2"], Set["Point2"]]) -> Union[int, float]:
        
        assert ps
        furthest_distance_squared = -math.inf
        for p2 in ps:
            if not isinstance(p2, Point2):
                p2 = p2.position
            distance = (self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2
            if furthest_distance_squared < distance:
                furthest_distance_squared = distance
        return furthest_distance_squared ** 0.5
583409
def _decdeg_distance(pt1, pt2):
    

    lat1, lon1 = pt1
    lat2, lon2 = pt2

    # Convert decimal degrees to radians
    lon1, lat1, lon2, lat2 = map(np.radians, [lon1, lat1, lon2, lat2])

    # haversine formula
    dlon = lon2 - lon1
    dlat = lat2 - lat1
    a = np.sin(dlat/2)**2 + np.cos(lat1) * np.cos(lat2) * np.sin(dlon/2)**2
    c = 2 * np.arcsin(np.sqrt(a))
    km = 6367 * c

    return km
209766
def _levenshtein_distance(s1, s2):
    
    if len(s1) > len(s2):
        s1, s2 = s2, s1
    distances = range(len(s1) + 1)
    for index2, num2 in enumerate(s2):
        new_distances = [index2 + 1]
        for index1, num1 in enumerate(s1):
            if num1 == num2:
                new_distances.append(distances[index1])
            else:
                new_distances.append(1 + min((distances[index1],
                                             distances[index1+1],
                                             new_distances[-1])))
        distances = new_distances
    return distances[-1]
220288
def distance_from(self, lat, lon):
        ''''''
        lat1 = self.pkt['I105']['Lat']['val']
        lon1 = self.pkt['I105']['Lon']['val']
        return mp_util.gps_distance(lat1, lon1, lat, lon)
1136711
def distance other, units = :km
        o = Itudes.new other
        raise ArgumentError.new "operand must be lat-/longitudable" if (o.latitude.nil? || o.longitude.nil?)

        dlat = Itudes.radians(o.latitude - @latitude)
        dlon = Itudes.radians(o.longitude - @longitude)
        lat1 = Itudes.radians(@latitude)
        lat2 = Itudes.radians(o.latitude);

        a = Math::sin(dlat/2)**2 + Math::sin(dlon/2)**2 * Math::cos(lat1) * Math::cos(lat2)
        (RADIUS[units] * 2.0 * Math::atan2(Math.sqrt(a), Math.sqrt(1-a))).abs
      end
1019031
public Double haversine(Position other) {
		double lon0r = toRadians(this.longitude);
		double lat0r = toRadians(this.latitude);
		double lon1r = toRadians(other.longitude);
		double lat1r = toRadians(other.latitude);
		double a = pow(sin((lat1r - lat0r) / 2.0), 2);
		double b = cos(lat0r) * cos(lat1r) * pow(sin((lon1r - lon0r) / 2.0), 2);

		return 6371000.0 * 2 * asin(sqrt(a + b));
	}
1145865
function getDistanceMatrices(areas, sets, setids) {
        // initialize an empty distance matrix between all the points
        var distances = zerosM(sets.length, sets.length),
            constraints = zerosM(sets.length, sets.length);

        // compute required distances between all the sets such that
        // the areas match
        areas.filter(function(x) { return x.sets.length == 2; })
            .map(function(current) {
            var left = setids[current.sets[0]],
                right = setids[current.sets[1]],
                r1 = Math.sqrt(sets[left].size / Math.PI),
                r2 = Math.sqrt(sets[right].size / Math.PI),
                distance$$1 = distanceFromIntersectArea(r1, r2, current.size);

            distances[left][right] = distances[right][left] = distance$$1;

            // also update constraints to indicate if its a subset or disjoint
            // relationship
            var c = 0;
            if (current.size + 1e-10 >= Math.min(sets[left].size,
                                                 sets[right].size)) {
                c = 1;
            } else if (current.size <= 1e-10) {
                c = -1;
            }
            constraints[left][right] = constraints[right][left] = c;
        });

        return {distances: distances, constraints: constraints};
    }