Last active
May 13, 2021 03:30
-
-
Save chuongmep/2b7636b2be3dbb243968767d976cd834 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Obtains the distance between two points. | |
/// </summary> | |
/// <param name="u">Vector3.</param> | |
/// <param name="v">Vector3.</param> | |
/// <returns>Distance.</returns> | |
public static double Distance(this XYZ u, XYZ v) | |
{ | |
return u.DistanceTo(v); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Obtains the distance between two points. | |
/// </summary> | |
/// <param name="u">Vector3.</param> | |
/// <param name="v">Vector3.</param> | |
/// <returns>Distance.</returns> | |
public static double Distance(this XYZ u, XYZ v) | |
{ | |
return Math.Sqrt(SquareDistance(u, v)); | |
} | |
/// <summary> | |
/// Obtains the square distance between two points. | |
/// </summary> | |
/// <param name="u">Vector3.</param> | |
/// <param name="v">Vector3.</param> | |
/// <returns>Square distance.</returns> | |
public static double SquareDistance(this XYZ u, XYZ v) | |
{ | |
return (u.X - v.X) * (u.X - v.X) + (u.Y - v.Y) * (u.Y - v.Y) + (u.Z - v.Z) * (u.Z - v.Z); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment