filter 1 for AFP extration: the distance of end-to-end
@param p1b
@param p1e
@param p2b
@param p2e
@return
432318
private static final double getEnd2EndDistance(Atom[] ca1, Atom[] ca2, int p1b, int p1e, int p2b, int p2e)
	{

		double min = 99;
			double dist1 = Calc.getDistance(ca1[p1b], ca1[p1e]);
			double dist2 = Calc.getDistance(ca2[p2b], ca2[p2e]);
			min = dist1 - dist2;

		return Math.abs(min);
	}
757866
private static boolean envelopeContainsEnvelope_(Envelope2D env_a,
			Envelope2D env_b, double tolerance, ProgressTracker progress_tracker) {
		if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance))
			return false;

		if (env_a.getHeight() <= tolerance && env_a.getWidth() <= tolerance) {
			Point2D pt_a = env_a.getCenter();
			return pointWithinEnvelope_(pt_a, env_b, tolerance,
					progress_tracker);
		}

		if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) {
			Point2D pt_b = env_b.getCenter();
			return pointWithinEnvelope_(pt_b, env_a, tolerance,
					progress_tracker);
		}

		if (env_a.getHeight() <= tolerance || env_a.getWidth() <= tolerance)
			return envelopeInfContainsEnvelope_(env_a, env_b, tolerance); // treat
																			// env_b
																			// as
																			// line

		// treat env_a as area

		if (env_b.getHeight() <= tolerance || env_b.getWidth() <= tolerance) {// treat
																				// env_b
																				// as
																				// line

			Envelope2D env_a_deflated = new Envelope2D();
			env_a_deflated.setCoords(env_a);
			env_a_deflated.inflate(-tolerance, -tolerance);

			if (env_a_deflated.containsExclusive(env_b))
				return true;

			Envelope2D env_inter = new Envelope2D();
			env_inter.setCoords(env_a_deflated);
			env_inter.intersect(env_b);

			if (env_inter.isEmpty()
					|| (env_inter.getHeight() <= tolerance && env_inter
							.getWidth() <= tolerance))
				return false;

			return true;
		}

		return envelopeInfContainsEnvelope_(env_a, env_b, tolerance);
	}
981365
public synchronized static boolean areConnectedUpstream(PfafstetterNumber p1,
                                                            PfafstetterNumber p2) {

        List<Integer> p1OrdersList = p1.getOrdersList();
        List<Integer> p2OrdersList = p2.getOrdersList();

        int levelDiff = p1OrdersList.size() - p2OrdersList.size();
        if (levelDiff == 0) {
            if (p1.toStringUpToLastLevel().equals(p2.toStringUpToLastLevel())) {
                int p1Last = p1OrdersList.get(p1OrdersList.size() - 1);
                int p2Last = p2OrdersList.get(p2OrdersList.size() - 1);
                if (p2Last == p1Last + 1 || p2Last == p1Last + 2) {
                    return p1Last % 2 != 0;
                }
            }
        } else if (levelDiff == -1) {
            if (p2.toString().startsWith(p1.toStringUpToLastLevel())) {
                int p2Last = p2OrdersList.get(p2OrdersList.size() - 1);
                if (p2Last != 1) {
                    return false;
                }
                int p1Last = p1OrdersList.get(p1OrdersList.size() - 1);
                int p2LastMinus1 = p2OrdersList.get(p2OrdersList.size() - 2);
                if (p2LastMinus1 == p1Last + 1 || p2Last == p1Last + 2) {
                    return p1Last % 2 != 0;
                }
            }
        }
        return false;
    }
107413
private double preDistanceMBR(SpatialComparable mbr1, SpatialComparable mbr2, final int start, final int end) {
    double agg = 0.;
    for(int d = start; d < end; d++) {
      double delta = mbr2.getMin(d) - mbr1.getMax(d);
      delta = delta >= 0 ? delta : mbr1.getMin(d) - mbr2.getMax(d);
      if(delta > 0.) {
        agg += MathUtil.powi(delta, intp);
      }
    }
    return agg;
  }
931881
@Override
	public float calculateDistance (T agentCurrPos, LinePathParam parameter) {
		// Find the nearest segment
		float smallestDistance2 = Float.POSITIVE_INFINITY;
		Segment<T> nearestSegment = null;
		for (int i = 0; i < segments.size; i++) {
			Segment<T> segment = segments.get(i);
			float distance2 = calculatePointSegmentSquareDistance(nearestPointOnCurrentSegment, segment.begin, segment.end,
				agentCurrPos);

			// first point
			if (distance2 < smallestDistance2) {
				nearestPointOnPath.set(nearestPointOnCurrentSegment);
				smallestDistance2 = distance2;
				nearestSegment = segment;
				parameter.segmentIndex = i;
			}
		}

		// Distance from path start
		float lengthOnPath = nearestSegment.cumulativeLength - nearestPointOnPath.dst(nearestSegment.end);

		parameter.setDistance(lengthOnPath);

		return lengthOnPath;
	}
778778
private static double distance(double[] p1, double[] p2) {
		switch (p1.length) {
			case 2: return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]));
			case 3: return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) + (p1[2] - p2[2]) * (p1[2] - p2[2]));
			default: {
				double dist = 0;
				for (int i = p1.length - 1; i >= 0; i--) {
					final double d = (p1[i] - p2[i]);
					dist += d * d;
				}
				return Math.sqrt(dist);
			}
		}
	}
647993
def distance_quat(p1, p2):
    
    if isinstance(p1, PoseStamped):
        p1 = pose_to_list(p1)
    if isinstance(p2, PoseStamped):
        p2 = pose_to_list(p2)
    if _is_indexable(p1) and _is_indexable(p1[0]):
        p1 = p1[1]
        p2 = p2[1]
    dotp = inner(array(p1), array(p2))
    return arccos(2 * dotp * dotp - 1)
1177723
@Override
	@Pure
	public <OT extends MapPonctualElement> double distance(OT another_point) {
		double dist = super.distance(another_point);
		dist -= this.radius;
		return dist;
	}
998491
def distance_to_point2(self, p2: "Point2") -> Union[int, float]:
        
        return ((self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2) ** 0.5
750950
public static double getSquaredDistanceToLine(
            final double pFromX, final double pFromY,
            final double pAX, final double pAY, final double pBX, final double pBY
    ) {
        return getSquaredDistanceToProjection(pFromX, pFromY, pAX, pAY, pBX, pBY,
                getProjectionFactorToLine(pFromX, pFromY, pAX, pAY, pBX, pBY));
    }
359455
public final Bounds getAdmissibleDistanceBounds(TimePoint tpTo) {
		final APSPSolver stpSolver = (APSPSolver) constraintSolvers[0];
		return stpSolver.getDistanceBounds(stpSolver.getSource(), tpTo);
	}
1181367
public static Double getDistanceWithinThresholdOfCoordinates(
            Tuple2<Double, Double> point1, Tuple2<Double, Double> point2) {
        throw new NotImplementedError();
    }
276684
@Override
    public boolean areEndPointsEqual(Object ep1, Object ep2)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "areEndPointsEqual", new Object[] { ep1, ep2 });

        boolean isEqual = false;

        if (ep1 instanceof CFEndPoint && ep2 instanceof CFEndPoint)
        {
            CFEndPoint cfEp1 = (CFEndPoint) ep1;
            CFEndPoint cfEp2 = (CFEndPoint) ep2;

            // The CFW does not provide an equals method for its endpoints.
            // We need to manually equals the important bits up
            isEqual = isEqual(cfEp1.getAddress(), cfEp2.getAddress()) &&
                      isEqual(cfEp1.getName(), cfEp2.getName()) &&
                      cfEp1.getPort() == cfEp2.getPort() &&
                      cfEp1.isLocal() == cfEp2.isLocal() &&
                      cfEp1.isSSLEnabled() == cfEp2.isSSLEnabled();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "areEndPointsEqual", Boolean.valueOf(isEqual));
        return isEqual;
    }
331440
public static final  void sortAfps(AFPChain afpChain, Atom[] ca1, Atom[] ca2)
	{


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

		if ( debug)
			System.err.println("entering sortAfps");

		int pro1Len = ca1.length;
		int pro2Len = ca2.length;

		afpChain.setAfpIndex(      new int[pro1Len][pro2Len]); //the index of (i,j) pair in AFP list, otherwise -1
		afpChain.setAfpAftIndex(   new int[pro1Len][pro2Len]);  //the index of AFP (i,j*) nearest to (i,j), j*<j. if a AFP exits for (i,j), it equals to afpIndex
		afpChain.setAfpBefIndex(   new int[pro1Len][pro2Len]); //the index of AFP (i,j*) nearest to (i,j), j*>j. if a AFP exits for (i,j), it equals to afpIndex

		int[][] afpIndex       = afpChain.getAfpIndex();
		int[][] afpAftIndex    = afpChain.getAfpAftIndex();
		int[][] afpBefIndex    = afpChain.getAfpBefIndex();

		for(int i = 0; i < pro1Len; i ++)   {
			for(int j = 0; j < pro2Len; j ++)   {

				afpIndex[i][j] = afpAftIndex[i][j] = afpBefIndex[i][j] = -1;
			}
		}

		//index the AFP for easy extraction of compatible AFPs
		int afpNum = afpSet.size();

		int     b0 = 0;
		for(int a = 0; a < afpNum; a ++)    {
			if(a == afpNum - 1 || afpSet.get(a).getP1() != afpSet.get(a+1).getP1())   {
				int i = afpSet.get(a).getP1();
				for(int b = b0; b <= a; b ++)       {
					int j = afpSet.get(b).getP2();
					afpIndex[i][j]=b ;
					afpBefIndex[i][j]=b;
					afpAftIndex[i][j]=b;
					if(afpSet.get(b).getP1() != i)    {
						System.err.println(String.format("Warning: wrong afp index %d %d\n", i, afpSet.get(b).getP1()));
						return;
					}
				}
				for(int k = 1; k < pro2Len; k ++)   {
					if( afpBefIndex[i][k] == -1){
						afpBefIndex[i][k] = afpBefIndex[i][k-1];
					}
				}
				for(int k = pro2Len - 2; k >= 0; k --)      {
					if(afpAftIndex[i][k] == -1) {
						afpAftIndex[i][k] =  afpAftIndex[i][k+1];
					}
				}
				b0 = a + 1;
			}
		}

		if ( debug)
			System.err.println("done sortAfps");


	}
1251505
public static double getClockwiseAngleBetweenThreePoints(final Point2D p0, final Point2D c, final Point2D p1)
    {
        final Point2D a = c.sub(p1);

        final Point2D b = c.sub(p0);

        return Math.atan2(a.getY(), a.getX()) - Math.atan2(b.getY(), b.getX());
    }
1066312
public static Integer distance(String h1, String h2) {
		HammingDistance distance = new HammingDistance();
		return distance.apply(h1, h2);
	}
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;
	}