/// <summary> /// Method to calculate distance between two points /// </summary> /// <param name="x1">The x value of the first point</param> /// <param name="y1">The y value of the first point</param> /// <param name="x2">The x value of the second point</param> /// <param name="y2">The y value of the second point</param> /// <returns>The distance between the two points</returns> static public double GetDistanceBetweenTwoPoints(double x1, double y1, double x2, double y2) { double deltaX = x2 - x1; double deltaY = y2 - y1; return(Arithmetic.GetRootValue(2, (Arithmetic.ElevateToPower(deltaX, 2) + Arithmetic.ElevateToPower(deltaY, 2)))); }
/// <summary> /// Method to get the magnitude of a vector /// </summary> /// <param name="vector">A double vector</param> /// <returns>The magnitude of the vector as a double</returns> static public double GetMagnitude(double[] vector) { double magnitude = 0; for (int i = 0; i < vector.Length; i++) { magnitude += Arithmetic.ElevateToPower(vector[i], 2); } return(Arithmetic.GetRootValue(2, magnitude)); }