diff options
author | don bright <hugh.m.bright@gmail.com> | 2012-08-20 23:33:13 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2012-08-20 23:33:13 (GMT) |
commit | f1d4a52f4cc01843f5d7c40499fcfe44cc82712f (patch) | |
tree | 2d6717a6deeed4157d84b07f45a41cc9d8f3b9e2 /src/linalg.cc | |
parent | 0170923b9bb51e198c8a3ad1b98ca5ed74a6c77d (diff) |
dont crash if there's infinity or NaN in transformation matrix
Diffstat (limited to 'src/linalg.cc')
-rw-r--r-- | src/linalg.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/linalg.cc b/src/linalg.cc index 30f23af..b0ea2b4 100644 --- a/src/linalg.cc +++ b/src/linalg.cc @@ -1,4 +1,5 @@ #include "linalg.h" +#include <boost/math/special_functions/fpclassify.hpp> // FIXME: We can achieve better pruning by either: // o Recalculate the box based on the transformed object @@ -25,3 +26,23 @@ BoundingBox operator*(const Transform3d &m, const BoundingBox &box) return newbox; } +bool matrix_contains_infinity( const Eigen::Transform3d &m ) +{ + for (int i=0;i<m.matrix().rows();i++) { + for (int j=0;j<m.matrix().cols();j++) { + if ((boost::math::isinf)(m(i,j))) return true; + } + } + return false; +} + +bool matrix_contains_nan( const Eigen::Transform3d &m ) +{ + for (int i=0;i<m.matrix().rows();i++) { + for (int j=0;j<m.matrix().cols();j++) { + if ((boost::math::isnan)(m(i,j))) return true; + } + } + return false; +} + |