Math/VectorI: Add Apply static method
This commit is contained in:
parent
addbb98671
commit
c826b537ab
|
|
@ -88,6 +88,7 @@ namespace Nz
|
||||||
constexpr bool operator>(const Vector2& vec) const;
|
constexpr bool operator>(const Vector2& vec) const;
|
||||||
constexpr bool operator>=(const Vector2& vec) const;
|
constexpr bool operator>=(const Vector2& vec) const;
|
||||||
|
|
||||||
|
static constexpr Vector2 Apply(T(*func)(T), const Vector2& vec);
|
||||||
static constexpr bool ApproxEqual(const Vector2& lhs, const Vector2& rhs, T maxDifference = std::numeric_limits<T>::epsilon());
|
static constexpr bool ApproxEqual(const Vector2& lhs, const Vector2& rhs, T maxDifference = std::numeric_limits<T>::epsilon());
|
||||||
template<typename U = T> static U Distance(const Vector2& vec1, const Vector2& vec2);
|
template<typename U = T> static U Distance(const Vector2& vec1, const Vector2& vec2);
|
||||||
static constexpr T DotProduct(const Vector2& vec1, const Vector2& vec2);
|
static constexpr T DotProduct(const Vector2& vec1, const Vector2& vec2);
|
||||||
|
|
|
||||||
|
|
@ -600,6 +600,12 @@ namespace Nz
|
||||||
return y >= vec.y;
|
return y >= vec.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr Vector2<T> Vector2<T>::Apply(T(*func)(T), const Vector2& vec)
|
||||||
|
{
|
||||||
|
return Vector2(func(vec.x), func(vec.y));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool Vector2<T>::ApproxEqual(const Vector2& lhs, const Vector2& rhs, T maxDifference)
|
constexpr bool Vector2<T>::ApproxEqual(const Vector2& lhs, const Vector2& rhs, T maxDifference)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ namespace Nz
|
||||||
constexpr bool operator>(const Vector3& vec) const;
|
constexpr bool operator>(const Vector3& vec) const;
|
||||||
constexpr bool operator>=(const Vector3& vec) const;
|
constexpr bool operator>=(const Vector3& vec) const;
|
||||||
|
|
||||||
|
static constexpr Vector3 Apply(T(*func)(T), const Vector3& vec);
|
||||||
static constexpr bool ApproxEqual(const Vector3& lhs, const Vector3& rhs, T maxDifference = std::numeric_limits<T>::epsilon());
|
static constexpr bool ApproxEqual(const Vector3& lhs, const Vector3& rhs, T maxDifference = std::numeric_limits<T>::epsilon());
|
||||||
static constexpr Vector3 Backward();
|
static constexpr Vector3 Backward();
|
||||||
static constexpr Vector3 Clamp(const Vector3& vec, const Vector3& min, const Vector3& max);
|
static constexpr Vector3 Clamp(const Vector3& vec, const Vector3& min, const Vector3& max);
|
||||||
|
|
|
||||||
|
|
@ -688,6 +688,12 @@ namespace Nz
|
||||||
return z >= vec.z;
|
return z >= vec.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr Vector3<T> Vector3<T>::Apply(T(*func)(T), const Vector3& vec)
|
||||||
|
{
|
||||||
|
return Vector3(func(vec.x), func(vec.y), func(vec.z));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool Vector3<T>::ApproxEqual(const Vector3& lhs, const Vector3& rhs, T maxDifference)
|
constexpr bool Vector3<T>::ApproxEqual(const Vector3& lhs, const Vector3& rhs, T maxDifference)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ namespace Nz
|
||||||
constexpr bool operator>(const Vector4& vec) const;
|
constexpr bool operator>(const Vector4& vec) const;
|
||||||
constexpr bool operator>=(const Vector4& vec) const;
|
constexpr bool operator>=(const Vector4& vec) const;
|
||||||
|
|
||||||
|
static constexpr Vector4 Apply(T(*func)(T), const Vector4& vec);
|
||||||
static constexpr bool ApproxEqual(const Vector4& lhs, const Vector4& rhs, T maxDifference = std::numeric_limits<T>::epsilon());
|
static constexpr bool ApproxEqual(const Vector4& lhs, const Vector4& rhs, T maxDifference = std::numeric_limits<T>::epsilon());
|
||||||
static constexpr T DotProduct(const Vector4& vec1, const Vector4& vec2);
|
static constexpr T DotProduct(const Vector4& vec1, const Vector4& vec2);
|
||||||
static constexpr Vector4 Lerp(const Vector4& from, const Vector4& to, T interpolation);
|
static constexpr Vector4 Lerp(const Vector4& from, const Vector4& to, T interpolation);
|
||||||
|
|
|
||||||
|
|
@ -644,6 +644,12 @@ namespace Nz
|
||||||
return w >= vec.w;
|
return w >= vec.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr Vector4<T> Vector4<T>::Apply(T(*func)(T), const Vector4& vec)
|
||||||
|
{
|
||||||
|
return Vector4(func(vec.x), func(vec.y), func(vec.z), func(vec.w));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool Vector4<T>::ApproxEqual(const Vector4& lhs, const Vector4& rhs, T maxDifference)
|
constexpr bool Vector4<T>::ApproxEqual(const Vector4& lhs, const Vector4& rhs, T maxDifference)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue