diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index 29f205431..816760fd5 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -79,6 +79,10 @@ class NzVector2 bool operator==(const NzVector2& vec) const; bool operator!=(const NzVector2& vec) const; + bool operator<(const NzVector2& vec) const; + bool operator<=(const NzVector2& vec) const; + bool operator>(const NzVector2& vec) const; + bool operator>=(const NzVector2& vec) const; static NzVector2 Lerp(const NzVector2& from, const NzVector2& to, T interpolation); static NzVector2 UnitX(); diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index f05ebe7e0..a9afe0de7 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -414,6 +414,33 @@ bool NzVector2::operator!=(const NzVector2& vec) const return !operator==(vec); } +template +bool NzVector2::operator<(const NzVector2& vec) const +{ + if (x == vec.x) + return y < vec.y; + else + return x < vec.x; +} + +template +bool NzVector2::operator<=(const NzVector2& vec) const +{ + return operator<(vec) || operator==(vec); +} + +template +bool NzVector2::operator>(const NzVector2& vec) const +{ + return !operator<=(vec); +} + +template +bool NzVector2::operator>=(const NzVector2& vec) const +{ + return !operator<(vec); +} + template NzVector2 NzVector2::Lerp(const NzVector2& from, const NzVector2& to, T interpolation) { diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 6fc3fc34e..d65b764b9 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -87,6 +87,10 @@ template class NzVector3 bool operator==(const NzVector3& vec) const; bool operator!=(const NzVector3& vec) const; + bool operator<(const NzVector3& vec) const; + bool operator<=(const NzVector3& vec) const; + bool operator>(const NzVector3& vec) const; + bool operator>=(const NzVector3& vec) const; static NzVector3 CrossProduct(const NzVector3& vec1, const NzVector3& vec2); static T DotProduct(const NzVector3& vec1, const NzVector3& vec2); diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index b714f8165..e070f8714 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -473,6 +473,38 @@ bool NzVector3::operator!=(const NzVector3& vec) const return !operator==(vec); } +template +bool NzVector3::operator<(const NzVector3& vec) const +{ + if (x == vec.x) + { + if (y < vec.y) + return z < vec.z; + else + return y < vec.y; + } + else + return x < vec.x; +} + +template +bool NzVector3::operator<=(const NzVector3& vec) const +{ + return operator<(vec) || operator==(vec); +} + +template +bool NzVector3::operator>(const NzVector3& vec) const +{ + return !operator<=(vec); +} + +template +bool NzVector3::operator>=(const NzVector3& vec) const +{ + return !operator<(vec); +} + template NzVector3 NzVector3::CrossProduct(const NzVector3& vec1, const NzVector3& vec2) { diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index 15126d9d1..9daa32507 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -71,6 +71,10 @@ template class NzVector4 bool operator==(const NzVector4& vec) const; bool operator!=(const NzVector4& vec) const; + bool operator<(const NzVector4& vec) const; + bool operator<=(const NzVector4& vec) const; + bool operator>(const NzVector4& vec) const; + bool operator>=(const NzVector4& vec) const; static NzVector4 UnitX(); static NzVector4 UnitY(); diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 0def605db..e3c7706b1 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -425,6 +425,43 @@ bool NzVector4::operator!=(const NzVector4& vec) const return !operator==(vec); } +template +bool NzVector4::operator<(const NzVector4& vec) const +{ + if (x == vec.x) + { + if (y == vec.y) + { + if (z == vec.z) + return w < vec.w; + else + return z < vec.z; + } + else + return y < vec.y; + } + else + return x < vec.x; +} + +template +bool NzVector4::operator<=(const NzVector4& vec) const +{ + return operator<(vec) || operator==(vec); +} + +template +bool NzVector3::operator>(const NzVector3& vec) const +{ + return !operator<=(vec); +} + +template +bool NzVector3::operator>=(const NzVector3& vec) const +{ + return !operator<(vec); +} + template NzVector4 NzVector4::UnitX() {