From 147f1bc1cfd5ad674797e339a355a4695c32d6d0 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Mon, 1 May 2023 17:05:26 +0200 Subject: [PATCH] Math/Vector3: Add GetAbs method --- include/Nazara/Math/Vector3.hpp | 1 + include/Nazara/Math/Vector3.inl | 10 ++++++++++ 2 files changed, 11 insertions(+) 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