add comparision overloads for tests

This commit is contained in:
Michael Kirsch 2019-07-03 22:15:26 +02:00 committed by Joseph Lenox
parent 9e39077035
commit 366c25888c
3 changed files with 25 additions and 0 deletions

View File

@ -57,6 +57,25 @@ void TransformationMatrix::swap(TransformationMatrix &other)
std::swap(this->m33, other.m33); std::swap(this->m34, other.m34); 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<double> TransformationMatrix::matrix3x4f() const std::vector<double> TransformationMatrix::matrix3x4f() const
{ {
std::vector<double> out_arr(0); std::vector<double> out_arr(0);

View File

@ -22,6 +22,9 @@ public:
TransformationMatrix& operator= (TransformationMatrix other); TransformationMatrix& operator= (TransformationMatrix other);
void swap(TransformationMatrix &other); void swap(TransformationMatrix &other);
bool operator== (const TransformationMatrix &other) const;
bool operator!= (const TransformationMatrix &other) const { return !(*this == other); };
/// matrix entries /// matrix entries
double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34; double m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34;

View File

@ -17,6 +17,9 @@
Clone<TransformationMatrix> inverse() Clone<TransformationMatrix> inverse()
%code{% RETVAL = THIS->inverse(); %}; %code{% RETVAL = THIS->inverse(); %};
bool equal(TransformationMatrix* other)
%code{% RETVAL = (*THIS == *other); %};
double determinante(); double determinante();
double m11() double m11()