Math/Vector3: Add Project method
This commit is contained in:
parent
61764dfc3d
commit
5180f24988
|
|
@ -52,6 +52,8 @@ namespace Nz
|
||||||
constexpr Vector3& Maximize(const Vector3& vec);
|
constexpr Vector3& Maximize(const Vector3& vec);
|
||||||
constexpr Vector3& Minimize(const Vector3& vec);
|
constexpr Vector3& Minimize(const Vector3& vec);
|
||||||
|
|
||||||
|
constexpr Vector3 Project(const Vector3& normal) const;
|
||||||
|
|
||||||
Vector3& Normalize(T* length = nullptr);
|
Vector3& Normalize(T* length = nullptr);
|
||||||
|
|
||||||
constexpr T SquaredDistance(const Vector3& vec) const;
|
constexpr T SquaredDistance(const Vector3& vec) const;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include "Vector3.hpp"
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
|
@ -282,6 +283,13 @@ namespace Nz
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr Vector3<T> Vector3<T>::Project(const Vector3& normal) const
|
||||||
|
{
|
||||||
|
float dot = DotProduct(normal);
|
||||||
|
return normal * dot;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Normalizes the current vector
|
* \brief Normalizes the current vector
|
||||||
* \return A reference to this vector
|
* \return A reference to this vector
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue