From 366c25888c15abb0f6b39e10a266297afceef7f7 Mon Sep 17 00:00:00 2001 From: Michael Kirsch Date: Wed, 3 Jul 2019 22:15:26 +0200 Subject: [PATCH] add comparision overloads for tests --- xs/src/libslic3r/TransformationMatrix.cpp | 19 +++++++++++++++++++ xs/src/libslic3r/TransformationMatrix.hpp | 3 +++ xs/xsp/TransformationMatrix.xsp | 3 +++ 3 files changed, 25 insertions(+) diff --git a/xs/src/libslic3r/TransformationMatrix.cpp b/xs/src/libslic3r/TransformationMatrix.cpp index 93f6d7a42..221654a9b 100644 --- a/xs/src/libslic3r/TransformationMatrix.cpp +++ b/xs/src/libslic3r/TransformationMatrix.cpp @@ -57,6 +57,25 @@ void TransformationMatrix::swap(TransformationMatrix &other) std::swap(this->m33, other.m33); std::swap(this->m34, other.m34); } +bool TransformationMatrix::operator==(const TransformationMatrix &other) const +{ + double eps = 1e-14; + bool is_equal = true; + is_equal &= (abs(this->m11 - other.m11) < eps); + is_equal &= (abs(this->m12 - other.m12) < eps); + is_equal &= (abs(this->m13 - other.m13) < eps); + is_equal &= (abs(this->m14 - other.m14) < eps); + is_equal &= (abs(this->m21 - other.m21) < eps); + is_equal &= (abs(this->m22 - other.m22) < eps); + is_equal &= (abs(this->m23 - other.m23) < eps); + is_equal &= (abs(this->m24 - other.m24) < eps); + is_equal &= (abs(this->m31 - other.m31) < eps); + is_equal &= (abs(this->m32 - other.m32) < eps); + is_equal &= (abs(this->m33 - other.m33) < eps); + is_equal &= (abs(this->m34 - other.m34) < eps); + return is_equal; +} + std::vector TransformationMatrix::matrix3x4f() const { std::vector out_arr(0); diff --git a/xs/src/libslic3r/TransformationMatrix.hpp b/xs/src/libslic3r/TransformationMatrix.hpp index f5e87fd46..6cf4b9ff2 100644 --- a/xs/src/libslic3r/TransformationMatrix.hpp +++ b/xs/src/libslic3r/TransformationMatrix.hpp @@ -22,6 +22,9 @@ public: TransformationMatrix& operator= (TransformationMatrix other); void swap(TransformationMatrix &other); + bool operator== (const TransformationMatrix &other) const; + bool operator!= (const TransformationMatrix &other) const { return !(*this == other); }; + /// matrix entries double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34; diff --git a/xs/xsp/TransformationMatrix.xsp b/xs/xsp/TransformationMatrix.xsp index 182655782..24c792765 100644 --- a/xs/xsp/TransformationMatrix.xsp +++ b/xs/xsp/TransformationMatrix.xsp @@ -17,6 +17,9 @@ Clone inverse() %code{% RETVAL = THIS->inverse(); %}; + bool equal(TransformationMatrix* other) + %code{% RETVAL = (*THIS == *other); %}; + double determinante(); double m11()