Skip to content

Commit 3d123fc

Browse files
committed
minor
1 parent 0c9b43f commit 3d123fc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

include/rotation.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#include <cmath>
55
#include "eigen3/Eigen/Eigen"
6+
#ifdef DEBUG
7+
#include <cstdio>
8+
#endif
69

710
namespace dso {
811
/** @brief Compare 3x3 rotation matrices.
@@ -26,7 +29,14 @@ namespace dso {
2629
*/
2730
inline double rotation_distance(const Eigen::Matrix<double, 3, 3> &P,
2831
const Eigen::Matrix<double, 3, 3> &Q) noexcept {
29-
return std::acos((P * Q.transpose()).trace() / 2e0);
32+
#ifdef DEBUG
33+
const double arg = ((P * Q.transpose()).trace() - 1e0) / 2e0;
34+
/* watch out for domain error ! */
35+
if (std::abs(arg)>1e0) {
36+
fprintf(stderr, "[ERROR] Domain error while comparing rotation matrices! arg for arccos is %.15e (traceback: %s)\n", arg, __func__);
37+
}
38+
#endif
39+
return std::acos(((P * Q.transpose()).trace() - 1e0) / 2e0);
3040
}
3141
} /* namespace dso */
3242

0 commit comments

Comments
 (0)