Implemented static functions for length and length squared for Vectors

This commit is contained in:
Andrej Stojkovikj
2023-09-19 16:09:18 +02:00
parent 3f299f4cf6
commit 8930c7ba56
2 changed files with 36 additions and 0 deletions

View File

@@ -821,6 +821,24 @@ namespace FlaxEngine
return value;
}
/// <summary>
/// Returns the length of a vector.
/// </summary>
/// <param name="vector">The vector to get the length from.</param>
public static Real Length(Vector2 vector)
{
return (Real)Mathf.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
}
/// <summary>
/// Returns the length squared of a vector.
/// </summary>
/// <param name="vector">The vector to get the length squared from.</param>
public static Real LengthSquared(Vector2 vector)
{
return vector.X * vector.X + vector.Y * vector.Y;
}
/// <summary>
/// Makes sure that Length of the output vector is always below max and above 0.
/// </summary>

View File

@@ -963,6 +963,24 @@ namespace FlaxEngine
return value;
}
/// <summary>
/// Returns the length of a vector.
/// </summary>
/// <param name="vector">The vector to get the length from.</param>
public static Real Length(Vector3 vector)
{
return (Real)Mathf.Sqrt(vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z);
}
/// <summary>
/// Returns the length squared of a vector.
/// </summary>
/// <param name="vector">The vector to get the length squared from.</param>
public static Real LengthSquared(Vector3 vector)
{
return vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z;
}
/// <summary>
/// Makes sure that Length of the output vector is always below max and above 0.
/// </summary>