Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MatrixTestHelper.hh
1 /*
2  * MatrixTestHelper.hh
3  *
4  * Created on: Oct 5, 2016
5  * Author: ebke
6  */
7 
8 #ifndef ACG_TESTS_MATH_MATRIXTESTHELPER_HH_
9 #define ACG_TESTS_MATH_MATRIXTESTHELPER_HH_
10 
11 #include <ACG/Math/Matrix3x3T.hh>
12 #include <gtest/gtest.h>
13 #include <cmath>
14 
15 template<typename Scalar>
16 ::testing::AssertionResult areClose(OpenMesh::VectorT<Scalar, 3> a,
17  OpenMesh::VectorT<Scalar, 3> b, double threshold = 1e-8) {
18 
19  if ((a-b).sqrnorm() > threshold) {
20  return ::testing::AssertionFailure()
21  << "ACG::Vec3d(" << a << ") and ACG::Vec3d(" << b << ") have distance "
22  << (a-b).norm() << ". Threshold: " << std::sqrt(threshold);
23  } else {
24  return ::testing::AssertionSuccess();
25  }
26 }
27 
28 template<typename Scalar>
29 ::testing::AssertionResult areClose(ACG::Matrix3x3T<Scalar> a, ACG::Matrix3x3T<Scalar> b, double threshold = 1e-8) {
30  if ((a-b).frobeniusSquared() > threshold) {
31  return ::testing::AssertionFailure()
32  << "ACG::Matrix3x3T(" << a << ") and ACG::Matrix3x3T(" << b << ") have frobenius distance "
33  << (a-b).frobenius() << ". Threshold: " << std::sqrt(threshold);
34  } else {
35  return ::testing::AssertionSuccess();
36  }
37 }
38 
39 #endif /* ACG_TESTS_MATH_MATRIXTESTHELPER_HH_ */