Implemented static functions for length and length squared for Vectors
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user