Calculates Tanimoto distance for two count fingerprints using method 2 {@cdk.cite Grant06}.

@param fp1 count fingerprint 1
@param fp2 count fingerprint 2
@return a Tanimoto distance
421083
public static double method2(ICountFingerprint fp1, ICountFingerprint fp2) {

        long maxSum = 0, minSum = 0;
        int i = 0, j = 0;
        while (i < fp1.numOfPopulatedbins() || j < fp2.numOfPopulatedbins()) {
            Integer hash1 = i < fp1.numOfPopulatedbins() ? fp1.getHash(i) : null;
            Integer hash2 = j < fp2.numOfPopulatedbins() ? fp2.getHash(j) : null;
            Integer count1 = i < fp1.numOfPopulatedbins() ? fp1.getCount(i) : null;
            Integer count2 = j < fp2.numOfPopulatedbins() ? fp2.getCount(j) : null;

            if (count2 == null || (hash1 != null && hash1 < hash2)) {
                maxSum += count1;
                i++;
                continue;
            }
            if (count1 == null || (hash2 != null && hash1 > hash2)) {
                maxSum += count2;
                j++;
                continue;
            }

            if (hash1.equals(hash2)) {
                maxSum += Math.max(count1, count2);
                minSum += Math.min(count1, count2);
                i++;
                j++;
            }
        }
        return ((double) minSum) / maxSum;
    }
218688
public double distanceSqCorner( Point2D_F64 p ) {
		double best = Double.MAX_VALUE;
		for (int i = 0; i < 4; i++) {
			double d = square.get(i).distance2(p);
			if( d < best ) {
				best = d;
			}
		}
		return best;
	}
521795
public double distance(double[] v1, double[] v2) {
    final int dim1 = v1.length, dim2 = v2.length;
    final int mindim = dim1 < dim2 ? dim1 : dim2;
    double agg = preDistance(v1, v2, 0, mindim);
    if(dim1 > mindim) {
      agg += preNorm(v1, mindim, dim1);
    }
    else if(dim2 > mindim) {
      agg += preNorm(v2, mindim, dim2);
    }
    return agg;
  }
1149822
private void findNeighbor(int p) {
        // if no neighbors available, set flag for UpdatePoint to find
        if (npoints == 1) {
            neighbor[p] = p;
            distance[p] = Float.MAX_VALUE;
            return;
        }

        // find first point unequal to p itself
        int first = 0;
        if (p == points[first]) {
            first = 1;
        }

        neighbor[p] = points[first];
        distance[p] = linkage.d(p, neighbor[p]);

        // now test whether each other point is closer
        for (int i = first + 1; i < npoints; i++) {
            int q = points[i];
            if (q != p) {
                float d = linkage.d(p, q);
                if (d < distance[p]) {
                    distance[p] = d;
                    neighbor[p] = q;
                }
            }
        }
    }
720294
def distance2_to(self, other: "Point2"):
        """"""
        assert isinstance(other, Point2)
        return (self[0] - other[0]) ** 2 + (self[1] - other[1]) ** 2
1181367
public static Double getDistanceWithinThresholdOfCoordinates(
            Tuple2<Double, Double> point1, Tuple2<Double, Double> point2) {
        throw new NotImplementedError();
    }
1349257
public double getSquaredDistance(final DBIDRef id1, final DBIDRef id2) {
    final int o1 = idmap.getOffset(id1), o2 = idmap.getOffset(id2);
    return kernel[o1][o1] + kernel[o2][o2] - 2 * kernel[o1][o2];
  }
1156608
public double distance(Instance first, Instance second) {
    return distance(first, second, Double.POSITIVE_INFINITY);
  }
346667
public static final double getAngleBetweenTwoLines(final Point2D p0, final Point2D p1, final Point2D p2)
    {
        return getAngleFromSSS(p0.distance(p1), p1.distance(p2), p0.distance(p2));
    }
1356225
public static final double distance(Point p1, Point p2)
    {
        return Math.hypot(p1.getX() - p2.getX(), p1.getY() - p2.getY());
    }
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
1153957
def distance(p1, p2):
    
    R = 6371

    lat1, lon1 = p1
    lat2, lon2 = p2

    phi1 = radians(lat1)
    phi2 = radians(lat2)
    delta_lat = radians(lat2 - lat1)
    delta_lon = radians(lon2 - lon1)

    a = haversin(delta_lat) + cos(phi1) * cos(phi2) * haversin(delta_lon)
    return 2 * R * atan2(sqrt(a), sqrt(1 - a))
922981
function (e) {
                if (e.targetTouches.length < 2) return 1;
                var x1 = e.targetTouches[0].pageX,
                    y1 = e.targetTouches[0].pageY,
                    x2 = e.targetTouches[1].pageX,
                    y2 = e.targetTouches[1].pageY;
                var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
                return distance;
            }
1152381
public FingerprintSimilarity getFingerprintsSimilarity() {
        HashMap<Integer, Integer> offset_Score_Table = new HashMap<>(); // offset_Score_Table<offset,count>
        int numFrames;
        float score = 0;
        int mostSimilarFramePosition = Integer.MIN_VALUE;

        // one frame may contain several points, use the shorter one be the denominator
        if (fingerprint1.length > fingerprint2.length) {
            numFrames = FingerprintManager.getNumFrames(fingerprint2);
        } else {
            numFrames = FingerprintManager.getNumFrames(fingerprint1);
        }

        // get the pairs
        PairManager pairManager = new PairManager();
        HashMap<Integer, List<Integer>> this_Pair_PositionList_Table =
                        pairManager.getPair_PositionList_Table(fingerprint1);
        HashMap<Integer, List<Integer>> compareWave_Pair_PositionList_Table =
                        pairManager.getPair_PositionList_Table(fingerprint2);

        for (Integer compareWaveHashNumber : compareWave_Pair_PositionList_Table.keySet()) {
            // if the compareWaveHashNumber doesn't exist in both tables, no need to compare
            if (!this_Pair_PositionList_Table.containsKey(compareWaveHashNumber)
                            || !compareWave_Pair_PositionList_Table.containsKey(compareWaveHashNumber)) {
                continue;
            }

            // for each compare hash number, get the positions
            List<Integer> wavePositionList = this_Pair_PositionList_Table.get(compareWaveHashNumber);
            List<Integer> compareWavePositionList = compareWave_Pair_PositionList_Table.get(compareWaveHashNumber);

            for (Integer thisPosition : wavePositionList) {
                for (Integer compareWavePosition : compareWavePositionList) {
                    int offset = thisPosition - compareWavePosition;
                    if (offset_Score_Table.containsKey(offset)) {
                        offset_Score_Table.put(offset, offset_Score_Table.get(offset) + 1);
                    } else {
                        offset_Score_Table.put(offset, 1);
                    }
                }
            }
        }

        // map rank
        MapRank mapRank = new MapRankInteger(offset_Score_Table, false);

        // get the most similar positions and scores	
        List<Integer> orderedKeyList = mapRank.getOrderedKeyList(100, true);
        if (orderedKeyList.size() > 0) {
            int key = orderedKeyList.get(0);
            // get the highest score position
            mostSimilarFramePosition = key;
            score = offset_Score_Table.get(key);

            // accumulate the scores from neighbours
            if (offset_Score_Table.containsKey(key - 1)) {
                score += offset_Score_Table.get(key - 1) / 2;
            }
            if (offset_Score_Table.containsKey(key + 1)) {
                score += offset_Score_Table.get(key + 1) / 2;
            }
        }

        /*
        Iterator<Integer> orderedKeyListIterator=orderedKeyList.iterator();
        while (orderedKeyListIterator.hasNext()){
        	int offset=orderedKeyListIterator.next();					
        	System.out.println(offset+": "+offset_Score_Table.get(offset));
        }
        */

        score /= numFrames;
        float similarity = score;
        // similarity >1 means in average there is at least one match in every frame
        if (similarity > 1) {
            similarity = 1;
        }

        fingerprintSimilarity.setMostSimilarFramePosition(mostSimilarFramePosition);
        fingerprintSimilarity.setScore(score);
        fingerprintSimilarity.setSimilarity(similarity);

        return fingerprintSimilarity;
    }
395860
function (pt1, pt2) {
    var lon1 = pt1.coordinates[0],
      lat1 = pt1.coordinates[1],
      lon2 = pt2.coordinates[0],
      lat2 = pt2.coordinates[1],
      dLat = this.numberToRadius(lat2 - lat1),
      dLon = this.numberToRadius(lon2 - lon1),
      a = Math.pow(Math.sin(dLat / 2), 2) + Math.cos(this.numberToRadius(lat1))
        * Math.cos(this.numberToRadius(lat2)) * Math.pow(Math.sin(dLon / 2), 2),
      c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    return (6371 * c) * 1000; // returns meters
  }
127479
private float distance(MotionEvent event) {
        if (event.getPointerCount() < 2) {
            return 0;
        }
        return PointF.length(event.getX(POINTER1) - event.getX(POINTER2), //
                event.getY(POINTER1) - event.getY(POINTER2));
    }
947593
public static boolean afpPairConn(int afp1, int afp2,  FatCatParameters params, AFPChain afpChain)

	{

		Double conn = afpChain.getConn();
		Double dvar = afpChain.getDVar();

		double misScore = params.getMisScore();
		double maxPenalty = params.getMaxPenalty();
		double disCut = params.getDisCut();
		double gapExtend = params.getGapExtend();
		double torsionPenalty = params.getTorsionPenalty();
		double disSmooth = params.getDisSmooth();

		List<AFP> afpSet = afpChain.getAfpSet();

		int     m = calcGap(afpSet.get(afp2),afpSet.get(afp1));
		int     g = calcMismatch(afpSet.get(afp2),afpSet.get(afp1));


		double  gp = misScore * m;      //on average, penalty for a mismatch is misScore, no modification on score
		if(g > 0)       {
			gp += gapExtend * g;
		}
		if(gp < maxPenalty)     gp = maxPenalty; //penalty cut-off
		//note: use < (smaller) instead of >, because maxPenalty is a negative number

		double  d;
		d = calAfpDis(afp1, afp2,params, afpChain);
		//note: the 'dis' value is numerically equivalent to the 'rms' with exceptions

		boolean     ch = false;
		double  tp = 0.0;
		if(d >= disCut) {
			tp = torsionPenalty;
			ch = true;
		} //use the variation of the distances between AFPs
		else  if(d > disCut - disSmooth)        {
			double  wt = Math.sqrt((d - disCut + disSmooth) / disSmooth);
			//using sqrt: penalty increase with dis more quicker than linear function
			tp = torsionPenalty * wt;
		}

		dvar = d;
		conn = tp + gp;

		afpChain.setConn(conn);
		afpChain.setDVar(dvar);
		return ch;
	}