Template Struct TBoundingBox_
Defined in File TBoundingBox.h
Struct Documentation
-
template<typename T>
struct TBoundingBox_ A bounding box defined by the 3D points at each minimum-maximum corner.
Public Functions
-
TBoundingBox_() = default
-
inline TBoundingBox_(const mrpt::math::TPoint3D_<T> &Min, const mrpt::math::TPoint3D_<T> &Max, const CTOR_FLAGS f = CTOR_FLAGS::NoFlags)
Ctor from min-max corners. A bounding box may have a zero volume if max==min. It is ilegal for a coordinate of the
maxvector to be smaller than itsmincounterpart, in which case an exception will be thrown, except if the flag CTOR_FLAGS::AllowUnordered is passed.
-
inline std::optional<TBoundingBox_<T>> intersection(const TBoundingBox_<T> &b, const T epsilon = static_cast<T>(1e-4)) const
Returns the intersection of this bounding box with “b”, or std::nullopt if no intersection exists. Note that borders are enlarged by “epsilon” before to testing for intersection to handle numerical innacuracies, for example on planar bounding boxes with a fixed “z”.
-
inline TBoundingBox_<T> unionWith(const TBoundingBox_<T> &b) const
Returns the union of this bounding box with “b”, i.e. a new bounding box comprising both
thisandb
-
inline void updateWithPoint(const mrpt::math::TPoint3D_<T> &p)
Expands the box limits to include the given point
-
inline bool containsPoint(const mrpt::math::TPoint3D_<T> &p) const
Returns true if the point lies within the bounding box (including the exact border)
Note
(New in MRPT 2.3.3)
-
template<typename POSE_T>
inline TBoundingBox_<T> compose(const POSE_T &pose) const Returns a new bounding box, transforming
thisfrom local coordinates to global coordinates, as ifthiswas given with respect topose, ie:return.min = pose \oplus this->min return.max = pose \oplus this->max
Note
If a rotation exists, the output bounding box will no longer be an accurate representation of the actual 3D box.
- Template Parameters:
POSE_T – Can be mrpt::poses::CPose3D, or mrpt::math::TPose3D
-
template<typename POSE_T>
inline TBoundingBox_<T> inverseCompose(const POSE_T &pose) const Returns a new bounding box, transforming
thisfrom global coordinates to local coordinates with respect topose, ie:return.min = this->min \ominus pose return.max = this->max \ominus pose
Note
If a rotation exists, the output bounding box will no longer be an accurate representation of the actual 3D box.
- Template Parameters:
POSE_T – Can be mrpt::poses::CPose3D, or mrpt::math::TPose3D
-
inline std::string asString() const
Print bounding box as a string with format “(minx,miny,minz)-(maxx,maxy,maxz)”
Note
Do not inherit from mrpt::Stringifyable to avoid virtual class table and keeping the class trivially-copiable.
-
inline bool operator==(const TBoundingBox_<T> &o) const
-
inline bool operator!=(const TBoundingBox_<T> &o) const
Public Members
Public Static Functions
-
static inline TBoundingBox_<T> PlusMinusInfinity()
Initialize with min=+Infinity, max=-Infinity. This is useful as an initial value before processing a list of points to keep their minimum/maximum.
-
static inline TBoundingBox_<T> FromUnsortedPoints(const mrpt::math::TPoint3D_<T> &pt1, const mrpt::math::TPoint3D_<T> &pt2)
Construct a bounding box from two points, by selecting their minimum and maximum (x,y,z) coordinates, so the point coordinates do not need to be already sorted by the user as one being the minimum and maximum corners.
Note
(New in MRPT 2.5.6)
-
TBoundingBox_() = default