Add Vector2.Normalized
This commit is contained in:
@@ -301,6 +301,19 @@ namespace FlaxEngine
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the normalized vector. Returned vector has length equal 1.
|
||||
/// </summary>
|
||||
public Vector2 Normalized
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector2 result = this;
|
||||
result.Normalize();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an array containing the elements of the vector.
|
||||
/// </summary>
|
||||
|
||||
@@ -223,6 +223,15 @@ public:
|
||||
return Vector2Base(-X, -Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates a normalized vector that has length equal to 1.
|
||||
/// </summary>
|
||||
Vector2Base GetNormalized() const
|
||||
{
|
||||
const T rcp = 1.0f / Length();
|
||||
return Vector2Base(X * rcp, Y * rcp);
|
||||
}
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Performs vector normalization (scales vector up to unit length).
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Serialization/JsonTools.h"
|
||||
|
||||
#include "Engine/Debug/DebugLog.h"
|
||||
|
||||
struct AxisEvaluation
|
||||
{
|
||||
float RawValue;
|
||||
|
||||
Reference in New Issue
Block a user