/// <summary> /// Calculates the euclidean distance between two points (distance formula). /// </summary> /// <param name="a">The parameter a represents the first point.</param> /// <param name="a">The parameter b represents the second point.</param> /// <returns>The square root of the squared distances between the two points.</returns> public static double EuclideanDistance(Points a, Points b) { return(Math.Sqrt(Math.Pow((a[1] - b[0]), 2) + Math.Pow((b[1] - a[0]), 2))); }
/// <summary> /// A private method to calculate the difference between two points at a given dimension. /// This method is essential to NNSearch's functions. /// </summary> /// <param name="a">The parameter a represents the first point.</param> /// <param name="a">The parameter b represents the second point.</param> /// <returns>The difference between two points at a given dimension.</returns> private static double Subtract(Points a, Points b, int dim) { return(a[dim] - b[dim]); }