diff --git a/Source/Engine/Core/Math/Vector2.cs b/Source/Engine/Core/Math/Vector2.cs index 568c51764..e953acfd6 100644 --- a/Source/Engine/Core/Math/Vector2.cs +++ b/Source/Engine/Core/Math/Vector2.cs @@ -821,6 +821,24 @@ namespace FlaxEngine return value; } + /// + /// Returns the length of a vector. + /// + /// The vector to get the length from. + public static Real Length(Vector2 vector) + { + return (Real)Mathf.Sqrt(vector.X * vector.X + vector.Y * vector.Y); + } + + /// + /// Returns the length squared of a vector. + /// + /// The vector to get the length squared from. + public static Real LengthSquared(Vector2 vector) + { + return vector.X * vector.X + vector.Y * vector.Y; + } + /// /// Makes sure that Length of the output vector is always below max and above 0. /// diff --git a/Source/Engine/Core/Math/Vector3.cs b/Source/Engine/Core/Math/Vector3.cs index 0ad557a32..c4bcf6979 100644 --- a/Source/Engine/Core/Math/Vector3.cs +++ b/Source/Engine/Core/Math/Vector3.cs @@ -963,6 +963,24 @@ namespace FlaxEngine return value; } + /// + /// Returns the length of a vector. + /// + /// The vector to get the length from. + public static Real Length(Vector3 vector) + { + return (Real)Mathf.Sqrt(vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z); + } + + /// + /// Returns the length squared of a vector. + /// + /// The vector to get the length squared from. + public static Real LengthSquared(Vector3 vector) + { + return vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z; + } + /// /// Makes sure that Length of the output vector is always below max and above 0. ///