Developer Documentation

MatrixTestHelper.hh
1
2 #ifndef ACG_TESTS_MATH_MATRIXTESTHELPER_HH_
3 #define ACG_TESTS_MATH_MATRIXTESTHELPER_HH_
4
5 #include <ACG/Math/Matrix3x3T.hh>
6 #include <gtest/gtest.h>
7 #include <cmath>
8
9 template<typename Scalar>
10 ::testing::AssertionResult areClose(OpenMesh::VectorT<Scalar, 3> a,
11 OpenMesh::VectorT<Scalar, 3> b, double threshold = 1e-8) {
12
13 if ((a-b).sqrnorm() > threshold) {
14 return ::testing::AssertionFailure()
15 << "ACG::Vec3d(" << a << ") and ACG::Vec3d(" << b << ") have distance "
16 << (a-b).norm() << ". Threshold: " << std::sqrt(threshold);
17 } else {
18 return ::testing::AssertionSuccess();
19 }
20 }
21
22 template<typename Scalar>
23 ::testing::AssertionResult areClose(ACG::Matrix3x3T<Scalar> a, ACG::Matrix3x3T<Scalar> b, double threshold = 1e-8) {
24 if ((a-b).frobeniusSquared() > threshold) {
25 return ::testing::AssertionFailure()
26 << "ACG::Matrix3x3T(" << a << ") and ACG::Matrix3x3T(" << b << ") have frobenius distance "
27 << (a-b).frobenius() << ". Threshold: " << std::sqrt(threshold);
28 } else {
29 return ::testing::AssertionSuccess();
30 }
31 }
32
33 #endif /* ACG_TESTS_MATH_MATRIXTESTHELPER_HH_ */
ACG::Matrix3x3T
Definition: Matrix3x3T.hh:22
OpenMesh::VectorT::norm
Scalar norm(const VectorT< Scalar, DIM > &_v)
Definition: MeshNode2T_impl.hh:275
OpenMesh::VectorT< Scalar, 3 >
OpenMesh::VectorT::sqrnorm
Scalar sqrnorm(const VectorT< Scalar, DIM > &_v)
Definition: MeshNode2T_impl.hh:283