package org.apache.commons.math.geometry;

public final class GeometryUtil {

  /**
   * Calculates the Euclidean distance between two points.
   *
   * @param p1 the first point
   * @param p2 the second point
   * @return the distance between the two points
   */
  public static final double euclideanDistance(double[] p1, double[] p2) {
    int sum = 0;
    for (int i = 0; i < p1.length; i++) {
      sum += Math.pow(p1[i] - p2[i], 2);
    }
    return Math.pow(sum, .5);
  }
  
  /**
   * Calculates the Euclidean distance between two points.
   *
   * @param p1 the first point
   * @param p2 the second point
   * @return the distance between the two points
   */
  public static final double euclideanDistance(int[] p1, int[] p2) {
    int sum = 0;
    for (int i = 0; i < p1.length; i++) {
      sum += Math.pow(p1[i] - p2[i], 2);
    }
    return Math.pow(sum, .5);
  }
  
}
