diff --git a/include/J3ML/LinearAlgebra/Vector3.h b/include/J3ML/LinearAlgebra/Vector3.h index ee161e9..02ecfe3 100644 --- a/include/J3ML/LinearAlgebra/Vector3.h +++ b/include/J3ML/LinearAlgebra/Vector3.h @@ -162,6 +162,10 @@ public: /// Unary - operator (Negation) Vector3 operator-() const; + bool Equals(const Vector3& rhs, float epsilon = 1e-3f) const; + bool Equals(float _x, float _y, float _z, float epsilon = 1e-3f) const; + + Vector3 &operator =(const Vector3& rhs); Vector3& operator+=(const Vector3& rhs); Vector3& operator-=(const Vector3& rhs); diff --git a/src/J3ML/LinearAlgebra/Vector3.cpp b/src/J3ML/LinearAlgebra/Vector3.cpp index a7517a1..5f2ab14 100644 --- a/src/J3ML/LinearAlgebra/Vector3.cpp +++ b/src/J3ML/LinearAlgebra/Vector3.cpp @@ -409,5 +409,17 @@ namespace J3ML::LinearAlgebra { return rhs.Abs(); } + bool Vector3::Equals(const Vector3 &rhs, float epsilon) const { + return std::abs(x - rhs.x) < epsilon && + std::abs(y - rhs.y) < epsilon && + std::abs(z - rhs.z) < epsilon; + } + + bool Vector3::Equals(float _x, float _y, float _z, float epsilon) const { + return std::abs(x - _x) < epsilon && + std::abs(y - _y) < epsilon && + std::abs(z - _z) < epsilon; + } + } \ No newline at end of file