template class mrpt::math::TOrientedBox_

Overview

3D oriented bounding box: defined by dimensions and pose

The box is described by the SE(3) pose of its geometric center, plus its lengths along the local (X’,Y’,Z’) axes determined by that pose.

Numbering of vertices:

    4 +---------+ 6
     /|        /|
    / |       / |
   /  |      /  |
5 +---------+ 7 |       +Z'
   |   |    |   |       ^
   |   |    |   |       |
   | 0 +----|---+ 2     +--->  +Y'
   |  /     |  /       /
   | /      | /       v
   |/       |/        +X'
1 +---------+ 3
#include <mrpt/math/TOrientedBox.h>

template <typename T>
class TOrientedBox_
{
public:
    // fields

    static constexpr static std::size_t PLANES_PER_BOX = 6;

    // construction

    TOrientedBox_();
    TOrientedBox_(const mrpt::math::TPose3D& center_pose, const mrpt::math::TPoint3D_<T>& box_size);
    TOrientedBox_(const TOrientedBox_<T>& o);

    // methods

    TOrientedBox_<T>& operator = (const TOrientedBox_<T>& o);

    template <typename U>
    mrpt::math::TOrientedBox_<U> cast() const;

    const std::vector<mrpt::math::TPoint3D_<T>>& vertices() const;
    const mrpt::math::TPose3D& pose() const;
    void setPose(const mrpt::math::TPose3D& p);
    const mrpt::math::TPoint3D_<T>& size() const;
    void setSize(const mrpt::math::TPoint3D_<T>& size);
    std::string asString() const;
    TBoundingBox_<T> getAxisAlignedBox() const;
    std::array<mrpt::math::TPlane, PLANES_PER_BOX> getBoxPlanes() const;
    bool operator == (const TOrientedBox_<T>& o) const;
    bool operator != (const TOrientedBox_<T>& o) const;
};

Fields

static constexpr static std::size_t PLANES_PER_BOX = 6

The number of planes defined by a box.

Construction

TOrientedBox_(const mrpt::math::TPose3D& center_pose, const mrpt::math::TPoint3D_<T>& box_size)

Constructor pose of the center and dimensions in local coordinates.

Methods

const std::vector<mrpt::math::TPoint3D_<T>>& vertices() const

Gets the 8 vertices (cached to avoid recalculation).

The order or vertices is ensured to be as defined above

const mrpt::math::TPose3D& pose() const

Gets the box center pose.

void setPose(const mrpt::math::TPose3D& p)

Changes the the box center SE(3) pose.

const mrpt::math::TPoint3D_<T>& size() const

Gets the box size (local coordinates)

void setSize(const mrpt::math::TPoint3D_<T>& size)

Changes the box size (local coordinates)

std::string asString() const

Returns a human-readable description of this box.

TBoundingBox_<T> getAxisAlignedBox() const

Returns the axis-aligned bounding box enclosing this oriented box.

std::array<mrpt::math::TPlane, PLANES_PER_BOX> getBoxPlanes() const

Returns the 6 planes enclosing the 3D box.

The ordering of the planes is: [0]=front, [1]=left, [2]=right, [3]=top, [4]=back, [5]=bottom. Plane normals are all pointing outwards