Calculate the perpendicular distance between the solution and reference line
325206
public double calculateDistance(S individual, double[] lambda,
                                  double[] z_, double[] nz_) {

    double scale;
    double distance;

    double[] vecInd = new double[problem.getNumberOfObjectives()];
    double[] vecProj = new double[problem.getNumberOfObjectives()];

    // normalize the weight vector (line segment)
    double nd = norm_vector(lambda);
    for (int i = 0; i < problem.getNumberOfObjectives(); i++) {
      lambda[i] = lambda[i] / nd;
    }

    // vecInd has been normalized to the range [0,1]
    for (int i = 0; i < problem.getNumberOfObjectives(); i++) {
      vecInd[i] = (individual.getObjective(i) - z_[i]) / (nz_[i] - z_[i]);
    }

    scale = innerproduct(vecInd, lambda);
    for (int i = 0; i < problem.getNumberOfObjectives(); i++) {
      vecProj[i] = vecInd[i] - scale * lambda[i];
    }

    distance = norm_vector(vecProj);

    return distance;
  }
944943
public void getClosestPoint(Vector2f point, Vector2f result) {
		loc.set(point);
		loc.sub(start);

		float projDistance = vec.dot(loc);

		projDistance /= vec.lengthSquared();

		if (projDistance < 0) {
			result.set(start);
			return;
		}
		if (projDistance > 1) {
			result.set(end);
			return;
		}

		result.x = start.getX() + projDistance * vec.getX();
		result.y = start.getY() + projDistance * vec.getY();
	}
502616
def distance_from_point(self, pt):
        
        return np.linalg.norm(np.array(pt) - self.coords)
1204691
def geo_distance(a, b):
    """"""
    a_y = radians(a.y)
    b_y = radians(b.y)
    delta_x = radians(a.x - b.x)
    cos_x = (sin(a_y) * sin(b_y) +
             cos(a_y) * cos(b_y) * cos(delta_x))
    return acos(cos_x) * earth_radius_km
136579
function (line, dist) {
        var sum = 0;

        if (dist <= 0) return line[0];

        for (var i = 0; i < line.length - 1; i++) {
            var p0 = line[i];
            var p1 = line[i + 1];
            var d = this.distance(p0, p1);
            sum += d;
            if (sum > dist) return interpolate(p0, p1, (dist - (sum - d)) / d);
        }

        return line[line.length - 1];
    }
1341039
def distance_to(self, other):
        """"""
        return np.linalg.norm(self.position-other.position)
711384
def _distance(coord1, coord2):
    
    xdist = coord1[0] - coord2[0]
    ydist = coord1[1] - coord2[1]
    return sqrt(xdist*xdist + ydist*ydist)
218184
function(p) {
        var v = this.b.sub(this.a);
        var t = p.sub(this.a).dot(v) / v.magSquared();
        // Check to see if t is beyond the extents of the line segment
        if (t < 0.0) {
            return this.a.copy();
        } else if (t > 1.0) {
            return this.b.copy();
        }
        // Return the point between 'a' and 'b'
        return this.a.add(v.scaleSelf(t));
    }
57760
def get_distance_term(self, C, rrup, mag):
        
        return (C["r1"] + C["r2"] * mag) *\
            np.log(np.sqrt(rrup ** 2. + C["h1"] ** 2.))
1355934
private int hammingDistance(BinarySolution solutionOne, BinarySolution solutionTwo) {
    int distance = 0;
    for (int i = 0; i < problem.getNumberOfVariables(); i++) {
      distance += hammingDistance(solutionOne.getVariableValue(i), solutionTwo.getVariableValue(i));
    }

    return distance;
  }
834141
def _compute_distance(self, rup, dists, C):
        
        mref = 3.6
        rref = 1.0
        rval = np.sqrt(dists.rhypo ** 2 + C['h'] ** 2)
        return (C['c1'] + C['c2'] * (rup.mag - mref)) *\
            np.log10(rval / rref) + C['c3'] * (rval - rref)
1290570
private double[] calculateDistanceBetweenAtomAndBond(IAtom proton, IBond theBond) {
        Point3d middlePoint = theBond.get3DCenter();
        Point3d protonPoint = proton.getPoint3d();
        double[] values = new double[4];
        values[0] = middlePoint.distance(protonPoint);
        values[1] = middlePoint.x;
        values[2] = middlePoint.y;
        values[3] = middlePoint.z;
        return values;
    }
110900
def distance(p_a, p_b):
    
    return sqrt((p_a.lat - p_b.lat) ** 2 + (p_a.lon - p_b.lon) ** 2)
1372341
def get_distance(a, b, xaxis=True):
    
    if xaxis:
        arange = ("0", a.qstart, a.qstop, a.orientation)  # 0 is the dummy chromosome
        brange = ("0", b.qstart, b.qstop, b.orientation)
    else:
        arange = ("0", a.sstart, a.sstop, a.orientation)
        brange = ("0", b.sstart, b.sstop, b.orientation)

    dist, oo = range_distance(arange, brange, distmode="ee")
    dist = abs(dist)

    return dist
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.))
1075469
private float distance(int i, float x, float y, float z) {
        return frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3];
    }
452308
function(ref, distance) {

            var theta = toRad((new Point(ref)).theta(this));
            var offset = this.offset(cos(theta) * distance, -sin(theta) * distance);
            return offset;
        }