Shapes - Bounding Boxes

For given shapes, these functions compute axis-aligned bounding boxes. Shapes include spheres, cylinders, and cuboids. Furthermore, they can have any orientation. The functions find the smallest box in which the specified shape fits completely.

Sphere

template<typename Scalar>
inline Eigen::AlignedBox<Scalar, 3> hector_math::computeBoundingBoxForSphere(Scalar radius, const Isometry3<Scalar> &transform)

Computes the axis-aligned bounding box for a sphere with the given radius centered at the location of the given transform.

Parameters:
  • radius – The radius of the sphere.

  • transform – The transform to the center of the sphere (only the translation is relevant).

Returns:

An axis-aligned bounding box for the given sphere.

Box

template<typename Scalar>
inline Eigen::AlignedBox<Scalar, 3> hector_math::computeBoundingBoxForBox(const Vector3<Scalar> &dim, const Isometry3<Scalar> &transform)

Computes the axis-aligned bounding box for a box with the given dimensions centered at the location of the given transform with the in the transform included rotation.

Parameters:
  • dim – The dimensions of the box.

  • transform – The transform to the center of the box.

Returns:

An axis-aligned bounding box for the given box.

Cylinder

template<typename Scalar>
inline Eigen::AlignedBox<Scalar, 3> hector_math::computeBoundingBoxForCylinder(Scalar radius, Scalar length, const Isometry3<Scalar> &transform)

Computes the axis-aligned bounding box for a cylinder with the given length in z-direction and radius in x-/y-direction centered at the location of the given transform with the rotation included in the transform.

Parameters:
  • radius – The radius of the cylinder in x-/y-direction.

  • length – The length of the cylinder in z-direction (this is the total length not half!).

  • transform – The transform to the center of the cylinder.

Returns:

An axis-aligned bounding box for the given cylinder.

Transform

template<typename Scalar>
inline Eigen::AlignedBox<Scalar, 3> hector_math::transformBoundingBox(const Eigen::AlignedBox<Scalar, 3> &box, const Isometry3<Scalar> &transform)

Transforms the given bounding box with the given transform (rotation + translation) and returns the minimal axis aligned bounding box that contains the transformed input box. The resulting bounding box may have a larger volume than the input box.

Parameters:
  • box – The box that is transformed.

  • transform – The transform that is applied to the box.

Returns:

The minimal axis aligned bounding box that contains the transformed input box.