Math/Vector3: Add ProjectOnPlane

This commit is contained in:
SirLynix 2024-02-22 19:11:25 +01:00
parent 5180f24988
commit e25fbe30e6
2 changed files with 8 additions and 0 deletions

View File

@ -53,6 +53,7 @@ namespace Nz
constexpr Vector3& Minimize(const Vector3& vec);
constexpr Vector3 Project(const Vector3& normal) const;
constexpr Vector3 ProjectOnPlane(const Vector3& normal) const;
Vector3& Normalize(T* length = nullptr);

View File

@ -290,6 +290,13 @@ namespace Nz
return normal * dot;
}
template<typename T>
constexpr Vector3<T> Vector3<T>::ProjectOnPlane(const Vector3& normal) const
{
float dot = DotProduct(normal);
return *this - normal * dot;
}
/*!
* \brief Normalizes the current vector
* \return A reference to this vector