Input for Distance. You have to option to use the shape radii in the
computation. Even
960106
function DistanceInput() {
  this.proxyA = new DistanceProxy();
  this.proxyB = new DistanceProxy();
  this.transformA = null;
  this.transformB = null;
  this.useRadii = false;
}
854784
function edit_distance(a, b) {
  // create a 2 dimensions array
  const m = a.length;
  const n = b.length;
  const dp = new Array(m + 1);
  for (let i = 0; i <= m; i++) {
    dp[i] = new Array(n + 1);
  }

  // init dp array
  for (let i = 0; i <= m; i++) {
    dp[i][0] = i;
  }
  for (let j = 0; j <= n; j++) {
    dp[0][j] = j;
  }

  // dynamic approach
  for (let i = 1; i <= m; i++) {
    for (let j = 1; j <= n; j++) {
      if (a[i - 1] !== b[j - 1]) {
        dp[i][j] = triple_min(
          1 + dp[i - 1][j], // deletion
          1 + dp[i][j - 1], // insertion
          1 + dp[i - 1][j - 1], // replacement
        );
      } else {
        dp[i][j] = dp[i - 1][j - 1];
      }
    }
  }
  return dp[m][n];
}
145036
def _compute_distance(cls, dists, coeffs):
        
        return coeffs['b3']*np.log10(np.sqrt(dists.rjb**2. + coeffs['b4']**2.))
343223
def compute_distance(m, l):
        '''
        '''

        if np.shape(m) != np.shape(l):
            raise ValueError("Input matrices are different sizes")
        if np.array_equal(m, l):
            # print("Trajectory %s and %s are equal" % (m, l))
            distance = 0
        else:
            distance = np.array(np.sum(cdist(m, l)), dtype=np.float32)

        return distance
1090546
def closestDirectDistance(arr, ksize=30, dtype=np.uint16):
    '''
    
    '''

    out = np.zeros_like(arr, dtype=dtype)
    _calc(out, arr, ksize)
    return out
1341039
def distance_to(self, other):
        """"""
        return np.linalg.norm(self.position-other.position)
84778
def distance_to(self, other):
        """"""

        other_coord = self._arith_check(other)
        return math.sqrt(math.pow(self._x - other_coord._x, 2) +
                         math.pow(self._y - other_coord._y, 2))
1048504
def distance(self, other):
        """"""
        return math.acos(self._pos3d.dot(other.vector))
142996
def _compute_distance_term(self, C, rup, dists):
        
        return (C['c4'] + C['c5'] * rup.mag) * \
            np.log(np.sqrt(dists.rrup ** 2. + C['c6'] ** 2.))
979918
function createDistanceArray(input, distance) {
  var length = input.length
  var matrix = new Array(length)
  for (var i = 0; i < length; i++) {
    matrix[i] = new Array(i)
    for (var j = 0; j < i; j++)
      matrix[i][j] = distance(input[i], input[j])
  }

  return matrix
}
500578
def neighbors(self, distance=2.0):
        """"""
        dgrid = self.distance_grid.reshape(self.num_neurons, self.num_neurons)
        for x, y in zip(*np.nonzero(dgrid <= distance)):
            if x != y:
                yield x, y
250306
def distance(self, val):
        
        tmp = 2
        try:
            int(val)
            if val > 0 and val <= 2:
                tmp = val
        except (ValueError, TypeError):
            pass
        self._distance = tmp
1036531
private static int computeDimension(ResultPoint topLeft,
                                      ResultPoint topRight,
                                      ResultPoint bottomLeft,
                                      float moduleSize) throws NotFoundException {
    int tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize);
    int tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize);
    int dimension = ((tltrCentersDimension + tlblCentersDimension) / 2) + 7;
    switch (dimension & 0x03) { // mod 4
      case 0:
        dimension++;
        break;
        // 1? do nothing
      case 2:
        dimension--;
        break;
      case 3:
        throw NotFoundException.getNotFoundInstance();
    }
    return dimension;
  }
1178103
private static double computeDistance(Geometry geometry, Point vertexPoint, double tolerance) {
        DistanceOp distanceOp = new DistanceOp(geometry, vertexPoint, tolerance);
        return distanceOp.distance();
    }
1109909
function computeDimension(topLeft, topRight, bottomLeft, matrix) {
        const moduleSize = (sum(countBlackWhiteRun(topLeft, bottomLeft, matrix, 5)) / 7 + // Divide by 7 since the ratio is 1:1:3:1:1
            sum(countBlackWhiteRun(topLeft, topRight, matrix, 5)) / 7 +
            sum(countBlackWhiteRun(bottomLeft, topLeft, matrix, 5)) / 7 +
            sum(countBlackWhiteRun(topRight, topLeft, matrix, 5)) / 7) / 4;
        if (moduleSize < 1) {
            throw new Error("Invalid module size");
        }
        const topDimension = Math.round(distance(topLeft, topRight) / moduleSize);
        const sideDimension = Math.round(distance(topLeft, bottomLeft) / moduleSize);
        let dimension = Math.floor((topDimension + sideDimension) / 2) + 7;
        switch (dimension % 4) {
            case 0:
                dimension++;
                break;
            case 2:
                dimension--;
                break;
        }
        return { dimension, moduleSize };
    }
801407
void computePointsAndWeights(EllipseRotated_F64 ellipse) {

		// use the semi-major axis to scale the input points for numerical stability
		double localScale = ellipse.a;

		samplePts.reset();
		weights.reset();
		int numSamples = radialSamples * 2 + 2;
		int numPts = numSamples - 1;

		Point2D_F64 sample = new Point2D_F64();
		for (int i = 0; i < numSampleContour; i++) {

			// find a point along the ellipse at evenly spaced angles
			double theta = 2.0 * Math.PI * i / numSampleContour;

			UtilEllipse_F64.computePoint(theta, ellipse, sample);

			// compute the unit tangent along the ellipse at this point
			double tanX = sample.x - ellipse.center.x;
			double tanY = sample.y - ellipse.center.y;
			double r = Math.sqrt(tanX * tanX + tanY * tanY);
			tanX /= r;
			tanY /= r;

			// define the line it will sample along
			double x = sample.x - numSamples * tanX / 2.0;
			double y = sample.y - numSamples * tanY / 2.0;

			double lengthX = numSamples * tanX;
			double lengthY = numSamples * tanY;

			// Unless all the sample points are inside the image, ignore this point
			if (!integral.isInside(x, y) || !integral.isInside(x + lengthX, y + lengthY))
				continue;

			double sample0 = integral.compute(x, y, x + tanX, y + tanY);
			x += tanX;
			y += tanY;
			for (int j = 0; j < numPts; j++) {
				double sample1 = integral.compute(x, y, x + tanX, y + tanY);

				double w = sample0 - sample1;
				if (w < 0) w = -w;

				if (w > 0) {
					// convert into a local coordinate so make the linear fitting more numerically stable and
					// independent on position in the image
					samplePts.grow().set((x - ellipse.center.x) / localScale, (y - ellipse.center.y) / localScale);
					weights.add(w);
				}

				x += tanX;
				y += tanY;
				sample0 = sample1;
			}

		}
	}
207233
def _initialize_distance_grid(self):
        """"""
        p = [self._grid_distance(i) for i in range(self.num_neurons)]
        return np.array(p)