distance from first fix point
976751
def distance_home(GPS_RAW):
    ''''''
    global first_fix
    if (hasattr(GPS_RAW, 'fix_type') and GPS_RAW.fix_type < 2) or \
       (hasattr(GPS_RAW, 'Status')   and GPS_RAW.Status   < 2):
        return 0

    if first_fix == None:
        first_fix = GPS_RAW
        return 0
    return distance_two(GPS_RAW, first_fix)
228541
def distance(self, x):
        """"""

        d = x - self.ctr

        return np.sqrt(np.dot(np.dot(d, self.am), d))
1353017
boolean findInitialTriangle(List<Point2D_I32> contour) {
		// find the first estimate for a corner
		int cornerSeed = findCornerSeed(contour);

		// see if it can reject the contour immediately
		if( convex ) {
			if( !isConvexUsingMaxDistantPoints(contour,0,cornerSeed))
				return false;
		}

		// Select the second corner.
		splitter.selectSplitPoint(contour,0,cornerSeed,resultsA);
		splitter.selectSplitPoint(contour,cornerSeed,0,resultsB);

		if( splitter.compareScore(resultsA.score,resultsB.score) >= 0 ) {
			addCorner(resultsA.index);
			addCorner(cornerSeed);
		} else {
			addCorner(cornerSeed);
			addCorner(resultsB.index);
		}

		// Select the third corner. Initial triangle will be complete now
		// the third corner will be the one which maximizes the distance from the first two
		int index0 = list.getHead().object.index;
		int index1 = list.getHead().next.object.index;
		int index2 = maximumDistance(contour,index0,index1);
		addCorner(index2);

		// enforce CCW requirement
		ensureTriangleOrder(contour);

		return initializeScore(contour, true);
	}
1237817
def point(self, t):
        """"""
        distance = self.end - self.start
        return self.start + distance*t
388994
def fast_distance(r1: 'Region', r2: 'Region'):
        
        return abs(r1.x - r2.x) + abs(r1.y - r2.y)
998491
def distance_to_point2(self, p2: "Point2") -> Union[int, float]:
        
        return ((self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2) ** 0.5
1288241
public static <S extends Solution<?>> double distanceBetweenObjectives(S firstSolution, S secondSolution) {

    double diff;
    double distance = 0.0;

    //euclidean distance
    for (int nObj = 0; nObj < firstSolution.getNumberOfObjectives(); nObj++) {
      diff = firstSolution.getObjective(nObj) - secondSolution.getObjective(nObj);
      distance += Math.pow(diff, 2.0);
    }

    return Math.sqrt(distance);
  }
720294
def distance2_to(self, other: "Point2"):
        """"""
        assert isinstance(other, Point2)
        return (self[0] - other[0]) ** 2 + (self[1] - other[1]) ** 2
389567
public static int distanceP(int index0, int index1, int size) {
		int difference = index1-index0;
		if( difference < 0 ) {
			difference = size+difference;
		}
		return difference;
	}
1159282
@Override
	public double calculatePhase1InitialFeasiblePoint(double[] originalNotFeasiblePoint, double tolerance){
		//DoubleMatrix1D X0NF = F1.make(originalNotFeasiblePoint);
		DoubleMatrix1D fiX0NF = F1.make(fi.length);
		for(int i=0; i<fi.length; i++){
			fiX0NF.set(i, this.fi[i].value(originalNotFeasiblePoint));
		}
		
		//lucky strike?
		int maxIneqIndex = Utils.getMaxIndex(fiX0NF);
		if(fiX0NF.get(maxIneqIndex) < 0){
			//the given notFeasible starting point is in fact already feasible
			return -1;
		}
		
		double s = Math.pow(tolerance,-0.5);
		for(int i=0; i<fiX0NF.size(); i++){
			s = Math.max(s, fiX0NF.get(i)*Math.pow(tolerance,-0.5));
		}
		
		return s;
	}
969682
function calculateTouchesDistance(startPoint, endPoint) {
			var diffX = Math.abs(startPoint.x - endPoint.x);
			var diffY = Math.abs(startPoint.y - endPoint.y);
				
			return Math.round(Math.sqrt(diffX*diffX+diffY*diffY));
		}
1245970
@Override
  public double getDistance(S solution, L solutionList) {
    List<Double> listOfDistances = knnDistances(solution, solutionList) ;
    listOfDistances.sort(Comparator.naturalOrder());

    int limit = Math.min(k, listOfDistances.size()) ;

    double result ;
    if (limit == 0) {
      result = 0.0 ;
    } else {
      double sum = 0.0;
      for (int i = 0; i < limit; i++) {
        sum += listOfDistances.get(i);
      }
      result = sum/limit ;
    }
    return result;
  }
433655
public int findClosest( P p , double maxDistance ) {
		int best = -1;
		bestDistance = maxDistance;

		for( int i = 0; i < points.size(); i++ ) {
			P c = points.get(i);

			double distanceC = distance.distance(p,c);

			if( distanceC <= bestDistance ) {
				bestDistance = distanceC;
				best = i;
			}
		}

		return best;
	}
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];
    }
355917
function(p, opt) {

            var segments = this.segments;
            var numSegments = segments.length;
            if (numSegments === 0) return null; // if segments is an empty array

            opt = opt || {};
            var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;
            var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;
            // not using localOpt

            var closestPointT;
            var minSquaredDistance = Infinity;
            for (var i = 0; i < numSegments; i++) {

                var segment = segments[i];
                var subdivisions = segmentSubdivisions[i];

                if (segment.isVisible) {
                    var segmentClosestPointT = segment.closestPointT(p, { precision: precision, subdivisions: subdivisions });
                    var segmentClosestPoint = segment.pointAtT(segmentClosestPointT);
                    var squaredDistance = (new Line(segmentClosestPoint, p)).squaredLength();

                    if (squaredDistance < minSquaredDistance) {
                        closestPointT = { segmentIndex: i, value: segmentClosestPointT };
                        minSquaredDistance = squaredDistance;
                    }
                }
            }

            if (closestPointT) return closestPointT;

            // if no visible segment, return end of last segment
            return { segmentIndex: numSegments - 1, value: 1 };
        }
755854
def _fixedpoint(D, tol=1e-7, maxiter=None):
    ''''''
    N, K = D.shape
    logp = log(D).mean(axis=0)
    a0 = _init_a(D)

    # Start updating
    if maxiter is None:
        maxiter = MAXINT
    for i in xrange(maxiter):
        a1 = _ipsi(psi(a0.sum()) + logp)
        # if norm(a1-a0) < tol:
        if abs(loglikelihood(D, a1)-loglikelihood(D, a0)) < tol: # much faster
            return a1
        a0 = a1
    raise Exception('Failed to converge after {} iterations, values are {}.'
                    .format(maxiter, a1))
610464
def fixpoint_runner(self):
        """"""
        q = self.cfg.nodes

        while q != []:
            x_i = constraint_table[q[0]]  # x_i = q[0].old_constraint
            self.analysis.fixpointmethod(q[0])  # y = F_i(x_1, ..., x_n);
            y = constraint_table[q[0]]  # y = q[0].new_constraint

            if y != x_i:
                for node in self.analysis.dep(q[0]):  # for (v in dep(v_i))
                    q.append(node)  # q.append(v):
                constraint_table[q[0]] = y  # q[0].old_constraint = q[0].new_constraint # x_i = y
            q = q[1:]