예제 #1
0
 public double euclideanDistance() {
   double out = 0.0d;
   long[] p1 = new long[numDimensions()];
   m_p1.localize(p1);
   long[] p2 = new long[numDimensions()];
   m_p2.localize(p2);
   for (int i = 0; i < numDimensions(); i++) {
     out += (p1[i] - p2[i]) * ((p1[i] - p2[i]));
   }
   return Math.sqrt(out);
 }
예제 #2
0
  @Override
  public boolean equals(Object arg) {
    if (arg == null || !(arg instanceof SplitLine)) {
      return false;
    }
    SplitLine<T> res = (SplitLine<T>) arg;

    if (res.numDimensions() != numDimensions()) return false;

    long[] p1 = new long[res.numDimensions()];
    res.getPoints().getFirst().localize(p1);
    long[] p2 = new long[res.numDimensions()];
    res.getPoints().getSecond().localize(p2);

    long[] m1 = new long[numDimensions()];
    m_p1.localize(m1);
    long[] m2 = new long[numDimensions()];
    m_p2.localize(m2);

    if (Arrays.equals(p1, m1) && Arrays.equals(p2, m2)
        || Arrays.equals(p1, m2) && Arrays.equals(p2, m1)) return true;
    else return false;
  }