Class Metric


  • public class Metric
    extends Object
    Provides methods to calculate different distances of points.
    • Constructor Summary

      Constructors 
      Constructor Description
      Metric()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double distance​(double[] pointA)
      Calculates the Euclidean length of a point.
      static double distance​(double[] pointA, double[] pointB)
      Calculates the Euclidean distance of two points.
      static double distance​(double[] pointA, double[] pointB, int offsetB)
      Calculates the Euclidean distance of two points.
      static double distanceSquared​(double[] pointA)
      Calculates the squared Euclidean length of a point.
      static double distanceSquared​(double[] pointA, double[] pointB)
      Calculates the squared Euclidean distance of two points.
      static double distanceSquared​(double[] pointA, double[] pointB, int offsetB)
      Calculates the squared Euclidean distance of two points.
      static double distanceWithDivision​(double[] pointA, double dA)
      Calculates the Euclidean length of a point divided by a scalar.
      static double distanceWithDivision​(double[] pointA, double dA, double[] pointB)
      Calculates the Euclidean distance of the first point divided by a scalar and another second point.
      static double distanceWithDivision​(double[] pointA, double dA, double[] pointB, double dB)
      Calculates the Euclidean distance of the first point divided by a first scalar and another second point divided by a second scalar.
      static double distanceWithDivisionSquared​(double[] pointA, double dA)
      Calculates the squared Euclidean length of a point divided by a scalar.
      static double distanceWithDivisionSquared​(double[] pointA, double dA, double[] pointB)
      Calculates the squared Euclidean distance of the first point divided by a scalar and another second point.
      static double distanceWithDivisionSquared​(double[] pointA, double dA, double[] pointB, double dB)
      Calculates the squared Euclidean distance of the first point divided by a first scalar and another second point divided by a second scalar.
      static double dotProduct​(double[] pointA)
      Calculates the dot product of the point with itself.
      static double dotProduct​(double[] pointA, double[] pointB)
      Calculates the dot product of the first point with a second point.
      static double dotProductWithAddition​(double[] pointA1, double[] pointA2, double[] pointB)
      Calculates the dot product of the addition of the first and the second point with the third point.
      static double dotProductWithAddition​(double[] pointA1, double[] pointA2, double[] pointB1, double[] pointB2)
      Calculates the dot product of the addition of the first and the second point with the addition of the third and the fourth point.
    • Constructor Detail

      • Metric

        public Metric()
    • Method Detail

      • distanceSquared

        public static double distanceSquared​(double[] pointA)
        Calculates the squared Euclidean length of a point.
        Parameters:
        pointA - point
        Returns:
        the squared Euclidean length
      • distance

        public static double distance​(double[] pointA)
        Calculates the Euclidean length of a point.
        Parameters:
        pointA - point
        Returns:
        the Euclidean length
      • distanceSquared

        public static double distanceSquared​(double[] pointA,
                                             double[] pointB,
                                             int offsetB)
        Calculates the squared Euclidean distance of two points. Starts at dimension offset + 1 of pointB.
        Parameters:
        pointA - first point
        pointB - second point
        offsetB - start dimension - 1 of pointB
        Returns:
        the squared Euclidean distance
      • distance

        public static double distance​(double[] pointA,
                                      double[] pointB,
                                      int offsetB)
        Calculates the Euclidean distance of two points. Starts at dimension offset + 1 of pointB.
        Parameters:
        pointA - first point
        pointB - second point
        offsetB - start dimension - 1 of pointB
        Returns:
        the Euclidean distance
      • distanceSquared

        public static double distanceSquared​(double[] pointA,
                                             double[] pointB)
        Calculates the squared Euclidean distance of two points.
        Parameters:
        pointA - first point
        pointB - second point
        Returns:
        the squared Euclidean distance
      • distance

        public static double distance​(double[] pointA,
                                      double[] pointB)
        Calculates the Euclidean distance of two points.
        Parameters:
        pointA - first point
        pointB - second point
        Returns:
        the Euclidean distance
      • distanceWithDivisionSquared

        public static double distanceWithDivisionSquared​(double[] pointA,
                                                         double dA)
        Calculates the squared Euclidean length of a point divided by a scalar.
        Parameters:
        pointA - point
        dA - scalar
        Returns:
        the squared Euclidean length
      • distanceWithDivision

        public static double distanceWithDivision​(double[] pointA,
                                                  double dA)
        Calculates the Euclidean length of a point divided by a scalar.
        Parameters:
        pointA - point
        dA - scalar
        Returns:
        the Euclidean length
      • distanceWithDivisionSquared

        public static double distanceWithDivisionSquared​(double[] pointA,
                                                         double dA,
                                                         double[] pointB)
        Calculates the squared Euclidean distance of the first point divided by a scalar and another second point.
        Parameters:
        pointA - first point
        dA - scalar
        pointB - second point
        Returns:
        the squared Euclidean distance
      • distanceWithDivision

        public static double distanceWithDivision​(double[] pointA,
                                                  double dA,
                                                  double[] pointB)
        Calculates the Euclidean distance of the first point divided by a scalar and another second point.
        Parameters:
        pointA - first point
        dA - scalar
        pointB - second point
        Returns:
        the Euclidean distance
      • distanceWithDivisionSquared

        public static double distanceWithDivisionSquared​(double[] pointA,
                                                         double dA,
                                                         double[] pointB,
                                                         double dB)
        Calculates the squared Euclidean distance of the first point divided by a first scalar and another second point divided by a second scalar.
        Parameters:
        pointA - first point
        dA - first scalar
        pointB - second point
        dB - second scalar
        Returns:
        the squared Euclidean distance
      • distanceWithDivision

        public static double distanceWithDivision​(double[] pointA,
                                                  double dA,
                                                  double[] pointB,
                                                  double dB)
        Calculates the Euclidean distance of the first point divided by a first scalar and another second point divided by a second scalar.
        Parameters:
        pointA - first point
        dA - first scalar
        pointB - second point
        dB - second scalar
        Returns:
        the Euclidean distance
      • dotProduct

        public static double dotProduct​(double[] pointA)
        Calculates the dot product of the point with itself.
        Parameters:
        pointA - point
        Returns:
        the dot product
      • dotProduct

        public static double dotProduct​(double[] pointA,
                                        double[] pointB)
        Calculates the dot product of the first point with a second point.
        Parameters:
        pointA - first point
        pointB - second point
        Returns:
        the dot product
      • dotProductWithAddition

        public static double dotProductWithAddition​(double[] pointA1,
                                                    double[] pointA2,
                                                    double[] pointB)
        Calculates the dot product of the addition of the first and the second point with the third point.
        Parameters:
        pointA1 - first point
        pointA2 - second point
        pointB - third point
        Returns:
        the dot product
      • dotProductWithAddition

        public static double dotProductWithAddition​(double[] pointA1,
                                                    double[] pointA2,
                                                    double[] pointB1,
                                                    double[] pointB2)
        Calculates the dot product of the addition of the first and the second point with the addition of the third and the fourth point.
        Parameters:
        pointA1 - first point
        pointA2 - second point
        pointB1 - third point
        pointB2 - fourth point
        Returns:
        the dot product