From d7d180ee3aee6ed6634e0e4f26ec5ba6820680c6 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco Claraco Date: Tue, 21 Sep 2021 23:49:54 +0200 Subject: [PATCH] add containsPoint() method --- doc/source/doxygen-docs/changelog.md | 1 + libs/math/include/mrpt/math/TBoundingBox.h | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/doc/source/doxygen-docs/changelog.md b/doc/source/doxygen-docs/changelog.md index d3989df8e2..d653f3d9f6 100644 --- a/doc/source/doxygen-docs/changelog.md +++ b/doc/source/doxygen-docs/changelog.md @@ -23,6 +23,7 @@ - \ref mrpt_math_grp - New function mrpt::math::xcorr() - New header ``, see \ref mrpt_gtsam_wrappers + - New method mrpt::math::TBoundingBox::containsPoint() - \ref mrpt_maps_grp - Optimization: mrpt::maps::CPointsMap::insertAnotherMap() avoids matrix multiplication if SE(3) identity is passed as insertion pose. - \ref mrpt_nav_grp diff --git a/libs/math/include/mrpt/math/TBoundingBox.h b/libs/math/include/mrpt/math/TBoundingBox.h index 13c6d55ff9..5b37f770d5 100644 --- a/libs/math/include/mrpt/math/TBoundingBox.h +++ b/libs/math/include/mrpt/math/TBoundingBox.h @@ -107,6 +107,16 @@ struct TBoundingBox_ mrpt::keep_max(max.z, p.z); } + /** Returns true if the point lies within the bounding box (including the + * exact border) + * \note (New in MRPT 2.3.3) + */ + bool containsPoint(const mrpt::math::TPoint3D_& p) const + { + return p.x >= min.x && p.y >= min.y && p.z >= min.z && p.x <= max.x && + p.y <= max.y && p.z <= max.z; + } + /** Returns a new bounding box, transforming `this` from local coordinates * to global coordinates, as if `this` was given with respect to `pose`, ie: *