AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::primal::OrientedBoundingBox< T, NDIMS > Class Template Reference

OrientedBoundingBox represents an oriented bounding box defined by its centroid, axes, and extents. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/primal/geometry/OrientedBoundingBox.hpp>

Public Types

using CoordType = T
 
using PointType = Point< T, NDIMS >
 
using VectorType = Vector< T, NDIMS >
 
using OrientedBoxType = OrientedBoundingBox< T, NDIMS >
 
using BoxType = BoundingBox< T, NDIMS >
 

Public Member Functions

 OrientedBoundingBox ()
 Constructor. Creates an invalid oriented bounding box by setting the first coordinate of the first axis to the smallest number of type T. More...
 
 OrientedBoundingBox (const PointType &pt)
 Constructor. Creates an oriented bounding box containing a single point. Extents are all zero, and axes are set to identity. More...
 
 OrientedBoundingBox (const PointType *pts, int n)
 Constructor. Creates an oriented bounding box from a collection of points. More...
 
 OrientedBoundingBox (const PointType &c, const VectorType(&u)[NDIMS], const VectorType &e)
 Constructor. Creates an oriented bounding box with given center, axes, and extents. Normalizes axes and sets any negative extent to 0. More...
 
 OrientedBoundingBox (const OrientedBoundingBox &other)
 Copy Constructor. More...
 
 ~OrientedBoundingBox ()
 Destructor. More...
 
void clear ()
 Resets the bounds to those of the default constructor. More...
 
const PointTypegetCentroid () const
 Returns the centroid (midpoint) of the bounding box. More...
 
const VectorTypegetAxes () const
 Return the axes. More...
 
const VectorTypegetExtents () const
 Returns the extents of the oriented bounding box. More...
 
std::vector< PointTypevertices () const
 Returns the vertices of the oriented bounding box. More...
 
int dimension () const
 Returns the dimension of the ambient space for this bounding box. More...
 
void addPoint (PointType pt)
 Expands the box so it contains the passed in point. More...
 
void addBox (OrientedBoxType obb)
 Expands the box so it contains the passed in box. More...
 
OrientedBoundingBoxexpand (T expansionAmount)
 Expands the extents by the given amount. More...
 
volume () const
 Returns the product of the extents. More...
 
OrientedBoundingBoxscale (double scaleFactor)
 Scales the bounding box about its center by a given amount. More...
 
OrientedBoundingBoxshift (const VectorType &displacement)
 Shifts the bounding box by a fixed displacement. More...
 
OrientedBoundingBoxoperator= (const OrientedBoundingBox &rhs)
 Overloaded assignment operator. More...
 
template<typename OtherType >
bool contains (const Point< OtherType, NDIMS > &otherPt, double EPS=1E-8) const
 Checks whether the box contains the point. More...
 
template<typename OtherType >
bool contains (const OrientedBoundingBox< OtherType, NDIMS > &otherOBB, double EPS=1E-8) const
 Checks whether the box fully contains another bounding box. More...
 
PointType toLocal (const PointType &pt) const
 Returns the same point but in the local coordinates of this OBB. More...
 
PointType furthestPoint (const PointType &pt) const
 Returns the furthest point in this OBB from pt. More...
 
bool isValid () const
 Checks if this bounding box is valid. More...
 
void bisect (OrientedBoxType &right, OrientedBoxType &left) const
 Subdivides this oriented bounding box instance into two sub-boxes by splitting along the longest dimension. More...
 
std::ostream & print (std::ostream &os) const
 Simple formatted print of a bounding box instance. More...
 

Static Public Member Functions

static void getPoints (const OrientedBoundingBox< T, NDIMS > &obb, std::vector< Point< T, NDIMS >> &pnts)
 Returns the list of vertices in an OBB instance. More...
 

Detailed Description

template<typename T, int NDIMS>
class axom::primal::OrientedBoundingBox< T, NDIMS >

OrientedBoundingBox represents an oriented bounding box defined by its centroid, axes, and extents.

Template Parameters
Tthe coordinate type, e.g., double, float, etc.
NDIMSthe number of dimensions

Member Typedef Documentation

◆ CoordType

template<typename T , int NDIMS>
using axom::primal::OrientedBoundingBox< T, NDIMS >::CoordType = T

◆ PointType

template<typename T , int NDIMS>
using axom::primal::OrientedBoundingBox< T, NDIMS >::PointType = Point<T, NDIMS>

◆ VectorType

template<typename T , int NDIMS>
using axom::primal::OrientedBoundingBox< T, NDIMS >::VectorType = Vector<T, NDIMS>

◆ OrientedBoxType

template<typename T , int NDIMS>
using axom::primal::OrientedBoundingBox< T, NDIMS >::OrientedBoxType = OrientedBoundingBox<T, NDIMS>

◆ BoxType

template<typename T , int NDIMS>
using axom::primal::OrientedBoundingBox< T, NDIMS >::BoxType = BoundingBox<T, NDIMS>

Constructor & Destructor Documentation

◆ OrientedBoundingBox() [1/5]

template<typename T , int NDIMS>
axom::primal::OrientedBoundingBox< T, NDIMS >::OrientedBoundingBox

Constructor. Creates an invalid oriented bounding box by setting the first coordinate of the first axis to the smallest number of type T.

◆ OrientedBoundingBox() [2/5]

template<typename T , int NDIMS>
axom::primal::OrientedBoundingBox< T, NDIMS >::OrientedBoundingBox ( const PointType pt)
explicit

Constructor. Creates an oriented bounding box containing a single point. Extents are all zero, and axes are set to identity.

◆ OrientedBoundingBox() [3/5]

template<typename T , int NDIMS>
axom::primal::OrientedBoundingBox< T, NDIMS >::OrientedBoundingBox ( const PointType pts,
int  n 
)

Constructor. Creates an oriented bounding box from a collection of points.

Initialize the random number generator before using this constructor (with srand()). This constructor uses eigen_solve to find a good fit around the passed-in points, which uses the random number generator.

References axom::primal::Point< T, NDIMS >::array(), AXOM_UNUSED_VAR, axom::numerics::matrix_scalar_multiply(), and SLIC_ASSERT.

◆ OrientedBoundingBox() [4/5]

template<typename T , int NDIMS>
axom::primal::OrientedBoundingBox< T, NDIMS >::OrientedBoundingBox ( const PointType c,
const VectorType(&)  u[NDIMS],
const VectorType e 
)

Constructor. Creates an oriented bounding box with given center, axes, and extents. Normalizes axes and sets any negative extent to 0.

Parameters
[in]ccenter of OBB
[in]uaxes of OBB
[in]eextents of OBB
Note
Axes are made orthonormal, but if they don't span, some will be set to 0.

◆ OrientedBoundingBox() [5/5]

template<typename T , int NDIMS>
axom::primal::OrientedBoundingBox< T, NDIMS >::OrientedBoundingBox ( const OrientedBoundingBox< T, NDIMS > &  other)

◆ ~OrientedBoundingBox()

template<typename T , int NDIMS>
axom::primal::OrientedBoundingBox< T, NDIMS >::~OrientedBoundingBox ( )
inline

Destructor.

Member Function Documentation

◆ clear()

template<typename T , int NDIMS>
void axom::primal::OrientedBoundingBox< T, NDIMS >::clear

Resets the bounds to those of the default constructor.

Note
This invalidates the bounding box (i.e. isValid() will be false).

◆ getCentroid()

template<typename T , int NDIMS>
const PointType& axom::primal::OrientedBoundingBox< T, NDIMS >::getCentroid ( ) const
inline

Returns the centroid (midpoint) of the bounding box.

Returns
Point at the bounding box centroid.

◆ getAxes()

template<typename T , int NDIMS>
const VectorType* axom::primal::OrientedBoundingBox< T, NDIMS >::getAxes ( ) const
inline

Return the axes.

Returns
Pointer to the axes.

◆ getExtents()

template<typename T , int NDIMS>
const VectorType& axom::primal::OrientedBoundingBox< T, NDIMS >::getExtents ( ) const
inline

Returns the extents of the oriented bounding box.

Returns
Extents in a vector.

◆ vertices()

template<typename T , int NDIMS>
std::vector< Point< T, NDIMS > > axom::primal::OrientedBoundingBox< T, NDIMS >::vertices

Returns the vertices of the oriented bounding box.

Returns
vertices in a std::vector<VectorType>.

◆ dimension()

template<typename T , int NDIMS>
int axom::primal::OrientedBoundingBox< T, NDIMS >::dimension ( ) const
inline

Returns the dimension of the ambient space for this bounding box.

Returns
d the dimension of this bounding box instance.
Postcondition
d >= 1.

◆ addPoint()

template<typename T , int NDIMS>
void axom::primal::OrientedBoundingBox< T, NDIMS >::addPoint ( PointType  pt)

Expands the box so it contains the passed in point.

Parameters
pt[in] point to add in
Note
Simply expands the extents of this box so that it contains pt, this loses optimality of the box. When constructing a box from a collection of points, the constructor which takes an array of points should be preferred.
Postcondition
this->contains(pt) == true

◆ addBox()

template<typename T , int NDIMS>
void axom::primal::OrientedBoundingBox< T, NDIMS >::addBox ( OrientedBoxType  obb)

Expands the box so it contains the passed in box.

Parameters
obb[in] OBB to add in
Note
If obb is invalid, this is a no-op
Expands the extents so this box contains obb. This loses optimality of the box for a better fit use merge_boxes in primal/compute_bounding_box.
Postcondition
this->contains(obb) == true

References axom::primal::OrientedBoundingBox< T, NDIMS >::isValid(), and axom::primal::OrientedBoundingBox< T, NDIMS >::vertices().

◆ expand()

template<typename T , int NDIMS>
OrientedBoundingBox< T, NDIMS > & axom::primal::OrientedBoundingBox< T, NDIMS >::expand ( expansionAmount)

Expands the extents by the given amount.

Parameters
[in]expansionAmountan absolute amount to expand
Note
This function checks to ensure the bounding box is valid afterwards.
Returns
A reference to the bounding box after it has been expanded.

◆ volume()

template<typename T , int NDIMS>
T axom::primal::OrientedBoundingBox< T, NDIMS >::volume ( ) const

Returns the product of the extents.

Returns
Product of the extents.

◆ scale()

template<typename T , int NDIMS>
OrientedBoundingBox< T, NDIMS > & axom::primal::OrientedBoundingBox< T, NDIMS >::scale ( double  scaleFactor)

Scales the bounding box about its center by a given amount.

Parameters
[in]scaleFactorthe multiplicative factor by which to scale
Note
Checks to ensure that the bounding box is valid after inflation.
If scaleFactor is less than 1, the bounding box will shrink.
If scaleFactor is 0, the bounding box will shrink to its midpoint towards the center, and we fix the bounds after shrinking
if scaleFactor is less than 0, we use -scaleFactor.
Returns
A reference to the bounding box after it has been scaled.

◆ shift()

template<typename T , int NDIMS>
OrientedBoundingBox< T, NDIMS > & axom::primal::OrientedBoundingBox< T, NDIMS >::shift ( const VectorType displacement)

Shifts the bounding box by a fixed displacement.

Parameters
[in]displacementthe amount with which to move the bounding box
Note
This function checks to ensure the bounding box is valid afterwards.
Returns
A reference to the bounding box after it has been shifted.

◆ operator=()

template<typename T , int NDIMS>
OrientedBoundingBox< T, NDIMS > & axom::primal::OrientedBoundingBox< T, NDIMS >::operator= ( const OrientedBoundingBox< T, NDIMS > &  rhs)

Overloaded assignment operator.

Parameters
[in]rhsoriented bounding box instance on the right-hand side
Returns

References axom::primal::OrientedBoundingBox< T, NDIMS >::getAxes(), axom::primal::OrientedBoundingBox< T, NDIMS >::getCentroid(), and axom::primal::OrientedBoundingBox< T, NDIMS >::getExtents().

◆ contains() [1/2]

template<typename T , int NDIMS>
template<typename OtherType >
bool axom::primal::OrientedBoundingBox< T, NDIMS >::contains ( const Point< OtherType, NDIMS > &  otherPt,
double  EPS = 1E-8 
) const

Checks whether the box contains the point.

Parameters
[in]otherPtthe point that we are checking
Returns
status true if point inside the box, else false.
Note
This function assumes all intervals are closed (i.e. contain their boundaries). We may need to deal with open and half open boundaries in the future.

◆ contains() [2/2]

template<typename T , int NDIMS>
template<typename OtherType >
bool axom::primal::OrientedBoundingBox< T, NDIMS >::contains ( const OrientedBoundingBox< OtherType, NDIMS > &  otherOBB,
double  EPS = 1E-8 
) const

Checks whether the box fully contains another bounding box.

Parameters
[in]otherOBBthe bounding box that we are checking
Returns
status true if bb is inside the box, else false.
Note
We are allowing the other bounding box to have a different coordinate type. This should work as long as the two Ts are comparable with operator<().

References axom::primal::OrientedBoundingBox< T, NDIMS >::vertices().

◆ toLocal()

template<typename T , int NDIMS>
Point< T, NDIMS > axom::primal::OrientedBoundingBox< T, NDIMS >::toLocal ( const PointType pt) const

Returns the same point but in the local coordinates of this OBB.

Parameters
[in]ptthe pt in world coords we want to convert to local coords
Returns
Vector which is just pt in local coordinates, i.e. is the projection of the difference between pt and m_c onto the axes m_u.

References axom::primal::Vector< T, NDIMS >::dot().

◆ furthestPoint()

template<typename T , int NDIMS>
Point< T, NDIMS > axom::primal::OrientedBoundingBox< T, NDIMS >::furthestPoint ( const PointType pt) const

Returns the furthest point in this OBB from pt.

Parameters
[in]ptthe pt we want to find the furthest point from
Note
If there are multiple furthest points, any one may be returned.
Returns
furthest point in this OBB from pt

References axom::primal::Vector< T, NDIMS >::array().

◆ isValid()

template<typename T , int NDIMS>
bool axom::primal::OrientedBoundingBox< T, NDIMS >::isValid

Checks if this bounding box is valid.

◆ bisect()

template<typename T , int NDIMS>
void axom::primal::OrientedBoundingBox< T, NDIMS >::bisect ( OrientedBoxType right,
OrientedBoxType left 
) const

Subdivides this oriented bounding box instance into two sub-boxes by splitting along the longest dimension.

Parameters
[in,out]rightthe right sub-box.
[in,out]leftthe left sub-box.

References axom::primal::Vector< T, NDIMS >::array(), and axom::utilities::max().

◆ print()

template<typename T , int NDIMS>
std::ostream & axom::primal::OrientedBoundingBox< T, NDIMS >::print ( std::ostream &  os) const

Simple formatted print of a bounding box instance.

Parameters
osThe output stream to write to
Returns
A reference to the modified ostream

◆ getPoints()

template<typename T , int NDIMS>
static void axom::primal::OrientedBoundingBox< T, NDIMS >::getPoints ( const OrientedBoundingBox< T, NDIMS > &  obb,
std::vector< Point< T, NDIMS >> &  pnts 
)
inlinestatic

Returns the list of vertices in an OBB instance.

Parameters
[in]bbthe OBB whose vertices will be returned
[out]pntsthe list of points
Postcondition
pnts.size() == (1 << NDIMS)

References axom::primal::OrientedBoundingBox< T, NDIMS >::vertices().


The documentation for this class was generated from the following file: