Computes the average distance between a list of points
    and a given point p0.
968195
def average_points_dist(p0, p_list):
    
    return np.mean(list(point_dist(p0, p1) for p1 in p_list))
434025
def _averageFromList(self, param):
        
        _result = 0.0
        _count = 0

        for _param in param.split(','):
            if _param != '' and float(_param) != 0.0:
                _result = _result + float(_param)
                _count  += 1

        if _count >= 1:
            _result = _result / _count
        return _result
901252
function boundPoints (points) {
  var bounds = new Array(points.length)
  for (var i = 0; i < points.length; ++i) {
    var p = points[i]
    bounds[i] = [
      nextafter(p[0], -Infinity),
      nextafter(p[1], -Infinity),
      nextafter(p[0], Infinity),
      nextafter(p[1], Infinity)
    ]
  }
  return bounds
}
729561
function geodesic_distance(cells, positions, p, max_distance, tolerance, stars) {

  if(typeof(max_distance) === "undefined") {
    max_distance = Number.POSITIVE_INFINITY
  }
  if(typeof(tolerance) === "undefined") {
    tolerance = 1e-4
  }
  if(typeof(dual) === "undefined") {
    stars = top.dual(cells, positions.length)
  }

  //First, run Dijkstra's algorithm to get an initial bound on the distance from each vertex
  // to the base point just using edge lengths
  var distances = dijkstra(p, stars, cells, positions, max_distance);
  
  //Then refine distances to acceptable threshold
  refine_distances(p, distances, positions, stars, cells, max_distance, tolerance);
  
  return distances;
}
666690
@Override
	public void computeDistance(List<Point2D> obs, double[] distance) {
		for( int i = 0; i < obs.size(); i++ ) {
			distance[i] = computeDistance(obs.get(i));
		}
	}
359717
def search_overlap(self, point_list):
        
        result = set()
        for j in point_list:
            self.search_point(j, result)
        return result
673384
public static float distance (int x0, int y0, int x1, int y1)
    {
        return (float)Math.sqrt(((x1 - x0) * (x1 - x0)) +
                                ((y1 - y0) * (y1 - y0)));
    }
1129445
public static <S extends Solution<?>> double averageDistanceToSolutionList(
          S solution,
          List<S> solutionList) {

    double sumOfDistances = 0.0;
    for (S sol : solutionList) {
      sumOfDistances += distanceBetweenObjectives(
              solution,
              sol);
    }

    return sumOfDistances / solutionList.size();
  }
810744
private List<Double> knnDistances(S solution, L solutionList) {
    List<Double> listOfDistances = new ArrayList<>() ;
    for (int i = 0 ; i< solutionList.size(); i++) {
      double distanceBetweenSolutions = distance.getDistance(solution, solutionList.get(i)) ;
      if (distanceBetweenSolutions != 0) {
        listOfDistances.add(distanceBetweenSolutions) ;
      }
    }

    return listOfDistances ;
  }
126617
def path_distance(points):
    
    vecs = np.diff(points, axis=0)[:, :3]
    d2 = [np.dot(p, p) for p in vecs]
    return np.sum(np.sqrt(d2))
998491
def distance_to_point2(self, p2: "Point2") -> Union[int, float]:
        
        return ((self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2) ** 0.5
166281
protected static double distance( LineGeneral2D_F64 line , Point2D_I32 p ) {
		return Math.abs(line.A*p.x + line.B*p.y + line.C);
	}
935123
def pointIsBetween(startP, endP, p):
    
    return (distancePoint(startP, p) + distancePoint(p, endP)
            - distancePoint(startP, endP) < 1e-6)
1108552
def distance(line, point):
    
    x0, y0, x1, y1 = line
    try:
        p1, p2 = point
    except ValueError:
        # line is given instead of point
        p1, p2 = middle(point)
    n1 = ascent(line)
    n2 = -1
    n0 = y0 - n1 * x0
    return abs(n1 * p1 + n2 * p2 + n0) / (n1 ** 2 + n2 ** 2) ** 0.5
61816
def distance(pos0, pos1):
    
    r0, pa0 = pos0
    #logging.debug('r0={}, pa0={} (from {})'.format(r0, pa0, self))
    ra0 = r0*np.sin(pa0*np.pi/180)
    dec0 = r0*np.cos(pa0*np.pi/180)

    r1, pa1 = pos1
    #logging.debug('r1={}, pa1={} (from {})'.format(r0, pa0, other))
    ra1 = r1*np.sin(pa1*np.pi/180)
    dec1 = r1*np.cos(pa1*np.pi/180)

    dra = (ra1 - ra0)
    ddec = (dec1 - dec0)
    return np.sqrt(dra**2 + ddec**2)
683261
def smooth_location_by_average(opts = {})
      seconds_either_side = opts[:averaging_window] || 20

      # calculate the first and last points to which the smoothing should be applied
      earliest = (find_point_by_time_or_offset(opts[:start]) || @earliest_point).time
      latest = (find_point_by_time_or_offset(opts[:end]) || @latest_point).time

      tmp_points = []

      @points.each do |point|
        if point.time > latest || point.time < earliest
          tmp_points.push point # add the point unaltered
          next
        end
        lat_av = 0.to_f
        lon_av = 0.to_f
        alt_av = 0.to_f
        n = 0
        # k ranges from the time of the current point +/- 20s
        (-1 * seconds_either_side..seconds_either_side).each do |k|
          # find the point nearest to the time offset indicated by k
          contributing_point = closest_point(point.time + k)
          # sum up the contributions to the average
          lat_av += contributing_point.lat
          lon_av += contributing_point.lon
          alt_av += contributing_point.elevation
          n += 1
        end
        # calculate the averages
        tmp_point = point.clone
        tmp_point.lon = (lon_av / n).round(7)
        tmp_point.elevation = (alt_av / n).round(2)
        tmp_point.lat = (lat_av / n).round(7)
        tmp_points.push tmp_point
      end
      @points.clear
      reset_meta_data
      # now commit the averages back and recalculate the distances
      tmp_points.each do |point|
        append_point(point)
      end
    end
502616
def distance_from_point(self, pt):
        
        return np.linalg.norm(np.array(pt) - self.coords)