diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 5991e8667..438227a83 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -43,6 +43,7 @@ namespace Nz U Distance(const Vector3& vec) const; T DotProduct(const Vector3& vec) const; + Vector3 GetAbs() const; T GetLength() const; float GetLengthf() const; Vector3 GetNormal(T* length = nullptr) const; diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index ec1cefd41..898d255a5 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -179,6 +179,16 @@ namespace Nz return x * vec.x + y * vec.y + z * vec.z; } + /*! + * \brief Returns the absolute of this vector, ie: Vector3(abs(x), abs(y), abs(z)) + * \return The absolute of this vector + */ + template + Vector3 Vector3::GetAbs() const + { + return Vector3(std::abs(x), std::abs(y), std::abs(z)); + } + /*! * \brief Calculates the length (magnitude) of the vector * \return The length of the vector