/// <summary> /// Calculates the Euclidean distance between two points. /// </summary> /// <param name="point1">Source point.</param> /// <param name="point2">Source point.</param> /// <returns>Returns the distance between the points squared.</returns> public static float distanceEuclideanSquared(FingerCoordinates point1, FingerCoordinates point2) { return((point1.X - point2.X) * (point1.X - point2.X) + (point1.Y - point2.Y) * (point1.Y - point2.Y)); }
/// <summary> /// Calculate the number of points you have to cross to go from one point to another. /// </summary> /// <param name="point1">Source point.</param> /// <param name="point2">Source point.</param> /// <returns>Returns the distance between the points.</returns> public static int distance(FingerCoordinates point1, FingerCoordinates point2) { return(Math.Abs(point1.X - point2.X) + Math.Abs(point1.Y - point2.Y)); }
/// <summary> /// Calculates the Euclidean distance between two points. /// </summary> /// <param name="point1">Source point.</param> /// <param name="point2">Source point.</param> /// <returns>Returns the distance between the points.</returns> public static float distanceEuclidean(FingerCoordinates point1, FingerCoordinates point2) { return((float)Math.Sqrt((point1.X - point2.X) * (point1.X - point2.X) + (point1.Y - point2.Y) * (point1.Y - point2.Y))); }
/// <summary> /// Returns the length of the source point. /// </summary> /// <returns>The length of the point.</returns> public static float length(FingerCoordinates point1) { return((float)Math.Sqrt(point1.X * point1.X + point1.Y * point1.Y)); }