AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
OrientedBoundingBox represents an oriented bounding box defined by its centroid, axes, and extents. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.7.0/src/axom/primal/geometry/OrientedBoundingBox.hpp>
Public Types | |
typedef T | CoordType |
typedef Point< T, NDIMS > | PointType |
typedef Vector< T, NDIMS > | VectorType |
typedef OrientedBoundingBox< T, NDIMS > | OrientedBoxType |
typedef BoundingBox< T, NDIMS > | BoxType |
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 PointType & | getCentroid () const |
Returns the centroid (midpoint) of the bounding box. More... | |
const VectorType * | getAxes () const |
Return the axes. More... | |
const VectorType & | getExtents () const |
Returns the extents of the oriented bounding box. More... | |
std::vector< PointType > | vertices () 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... | |
OrientedBoundingBox & | expand (T expansionAmount) |
Expands the extents by the given amount. More... | |
T | volume () const |
Returns the product of the extents. More... | |
OrientedBoundingBox & | scale (double scaleFactor) |
Scales the bounding box about its center by a given amount. More... | |
OrientedBoundingBox & | shift (const VectorType &displacement) |
Shifts the bounding box by a fixed displacement. More... | |
OrientedBoundingBox & | operator= (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... | |
OrientedBoundingBox represents an oriented bounding box defined by its centroid, axes, and extents.
T | the coordinate type, e.g., double, float, etc. |
NDIMS | the number of dimensions |
typedef T axom::primal::OrientedBoundingBox< T, NDIMS >::CoordType |
typedef Point<T, NDIMS> axom::primal::OrientedBoundingBox< T, NDIMS >::PointType |
typedef Vector<T, NDIMS> axom::primal::OrientedBoundingBox< T, NDIMS >::VectorType |
typedef OrientedBoundingBox<T, NDIMS> axom::primal::OrientedBoundingBox< T, NDIMS >::OrientedBoxType |
typedef BoundingBox<T, NDIMS> axom::primal::OrientedBoundingBox< T, NDIMS >::BoxType |
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.
References axom::primal::OrientedBoundingBox< T, NDIMS >::clear().
|
explicit |
Constructor. Creates an oriented bounding box containing a single point. Extents are all zero, and axes are set to identity.
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::primal::OrientedBoundingBox< T, NDIMS >::clear(), axom::numerics::matrix_scalar_multiply(), and SLIC_ASSERT.
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.
[in] | c | center of OBB |
[in] | u | axes of OBB |
[in] | e | extents of OBB |
axom::primal::OrientedBoundingBox< T, NDIMS >::OrientedBoundingBox | ( | const OrientedBoundingBox< T, NDIMS > & | other | ) |
Copy Constructor.
[in] | other | The oriented bounding box to copy |
References axom::primal::OrientedBoundingBox< T, NDIMS >::getAxes(), axom::primal::OrientedBoundingBox< T, NDIMS >::getCentroid(), and axom::primal::OrientedBoundingBox< T, NDIMS >::getExtents().
|
inline |
Destructor.
References axom::primal::OrientedBoundingBox< T, NDIMS >::clear().
void axom::primal::OrientedBoundingBox< T, NDIMS >::clear | ( | ) |
Resets the bounds to those of the default constructor.
|
inline |
Returns the centroid (midpoint) of the bounding box.
|
inline |
Return the axes.
|
inline |
Returns the extents of the oriented bounding box.
References axom::primal::OrientedBoundingBox< T, NDIMS >::vertices().
std::vector< Point< T, NDIMS > > axom::primal::OrientedBoundingBox< T, NDIMS >::vertices | ( | ) | const |
Returns the vertices of the oriented bounding box.
|
inline |
Returns the dimension of the ambient space for this bounding box.
References axom::primal::OrientedBoundingBox< T, NDIMS >::addBox(), axom::primal::OrientedBoundingBox< T, NDIMS >::addPoint(), axom::primal::OrientedBoundingBox< T, NDIMS >::bisect(), axom::primal::OrientedBoundingBox< T, NDIMS >::contains(), axom::primal::OrientedBoundingBox< T, NDIMS >::expand(), axom::primal::OrientedBoundingBox< T, NDIMS >::furthestPoint(), axom::primal::OrientedBoundingBox< T, NDIMS >::isValid(), axom::primal::OrientedBoundingBox< T, NDIMS >::operator=(), axom::primal::OrientedBoundingBox< T, NDIMS >::print(), axom::primal::OrientedBoundingBox< T, NDIMS >::scale(), axom::primal::OrientedBoundingBox< T, NDIMS >::shift(), axom::primal::OrientedBoundingBox< T, NDIMS >::toLocal(), and axom::primal::OrientedBoundingBox< T, NDIMS >::volume().
void axom::primal::OrientedBoundingBox< T, NDIMS >::addPoint | ( | PointType | pt | ) |
Expands the box so it contains the passed in point.
pt | [in] point to add in |
References axom::primal::OrientedBoundingBox< T, NDIMS >::toLocal().
void axom::primal::OrientedBoundingBox< T, NDIMS >::addBox | ( | OrientedBoxType | obb | ) |
Expands the box so it contains the passed in box.
obb | [in] OBB to add in |
References axom::primal::OrientedBoundingBox< T, NDIMS >::addPoint(), axom::primal::OrientedBoundingBox< T, NDIMS >::isValid(), SLIC_CHECK_MSG, and axom::primal::OrientedBoundingBox< T, NDIMS >::vertices().
OrientedBoundingBox< T, NDIMS > & axom::primal::OrientedBoundingBox< T, NDIMS >::expand | ( | T | expansionAmount | ) |
Expands the extents by the given amount.
[in] | expansionAmount | an absolute amount to expand |
T axom::primal::OrientedBoundingBox< T, NDIMS >::volume | ( | ) | const |
Returns the product of the extents.
OrientedBoundingBox< T, NDIMS > & axom::primal::OrientedBoundingBox< T, NDIMS >::scale | ( | double | scaleFactor | ) |
Scales the bounding box about its center by a given amount.
[in] | scaleFactor | the multiplicative factor by which to scale |
OrientedBoundingBox< T, NDIMS > & axom::primal::OrientedBoundingBox< T, NDIMS >::shift | ( | const VectorType & | displacement | ) |
Shifts the bounding box by a fixed displacement.
[in] | displacement | the amount with which to move the bounding box |
OrientedBoundingBox< T, NDIMS > & axom::primal::OrientedBoundingBox< T, NDIMS >::operator= | ( | const OrientedBoundingBox< T, NDIMS > & | rhs | ) |
Overloaded assignment operator.
[in] | rhs | oriented bounding box instance on the right-hand side |
References axom::primal::OrientedBoundingBox< T, NDIMS >::getAxes(), axom::primal::OrientedBoundingBox< T, NDIMS >::getCentroid(), and axom::primal::OrientedBoundingBox< T, NDIMS >::getExtents().
bool axom::primal::OrientedBoundingBox< T, NDIMS >::contains | ( | const Point< OtherType, NDIMS > & | otherPt, |
double | EPS = 1E-8 |
||
) | const |
Checks whether the box contains the point.
[in] | otherPt | the point that we are checking |
References axom::primal::OrientedBoundingBox< T, NDIMS >::isValid(), and axom::primal::OrientedBoundingBox< T, NDIMS >::toLocal().
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.
[in] | otherOBB | the bounding box that we are checking |
References axom::primal::OrientedBoundingBox< T, NDIMS >::contains(), and axom::primal::OrientedBoundingBox< T, NDIMS >::vertices().
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.
[in] | pt | the pt in world coords we want to convert to local coords |
References axom::primal::Vector< T, NDIMS >::dot().
Point< T, NDIMS > axom::primal::OrientedBoundingBox< T, NDIMS >::furthestPoint | ( | const PointType & | pt | ) | const |
Returns the furthest point in this OBB from pt.
[in] | pt | the pt we want to find the furthest point from |
References axom::primal::Vector< T, NDIMS >::array(), and axom::primal::OrientedBoundingBox< T, NDIMS >::toLocal().
bool axom::primal::OrientedBoundingBox< T, NDIMS >::isValid | ( | ) | const |
Checks if this bounding box is valid.
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.
[in,out] | right | the right sub-box. |
[in,out] | left | the left sub-box. |
References axom::primal::Vector< T, NDIMS >::array(), and axom::utilities::max().
std::ostream & axom::primal::OrientedBoundingBox< T, NDIMS >::print | ( | std::ostream & | os | ) | const |
Simple formatted print of a bounding box instance.
os | The output stream to write to |
References axom::primal::OrientedBoundingBox< T, NDIMS >::isValid().
|
inlinestatic |
Returns the list of vertices in an OBB instance.
[in] | bb | the OBB whose vertices will be returned |
[out] | pnts | the list of points |
References axom::primal::Vector< T, NDIMS >::array(), and axom::primal::OrientedBoundingBox< T, NDIMS >::vertices().