Math/Vector3: Add GetAbs method

This commit is contained in:
SirLynix 2023-05-01 17:05:26 +02:00
parent a578b061b4
commit 147f1bc1cf
2 changed files with 11 additions and 0 deletions

View File

@ -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;

View File

@ -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<typename T>
Vector3<T> Vector3<T>::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