olp-cpp-sdk  1.22.0
Public Types | Public Member Functions | Static Public Attributes | List of all members
olp::math::AlignedBox< T, N > Class Template Reference

The aligned bounding-box implementation. More...

#include <AlignedBox.h>

Public Types

using ValueType = T
 An alias for the box value type.
 
using OverflowType = typename OverflowTrait< T >::Type
 An alias for the overflow trait.
 
using VectorType = Vector< ValueType, N >
 An alias for the vector type of the box.
 
using OverflowVectorType = Vector< OverflowType, N >
 An alias for the overflow vector type.
 
using CornerArrayType = typename std::array< VectorType, numCorners >
 An alias for the corner points array type.
 

Public Member Functions

 AlignedBox ()
 Creates an AlignedBox instance. More...
 
 AlignedBox (const VectorType &min, const VectorType &max)
 Creates an AlignedBox instance. More...
 
template<typename OtherT >
 AlignedBox (const AlignedBox< OtherT, N > &other)
 Creates a copy of the AlignedBox instance. More...
 
void Reset ()
 Resets the box to empty.
 
void Reset (const VectorType &min, const VectorType &max)
 Resets the box to the new minimum and maximum points. More...
 
bool Empty () const
 Tests whether the box is empty. More...
 
VectorType Center () const
 Gets the center point of the box. More...
 
VectorType Size () const
 Gets the size of the box. More...
 
const VectorTypeMinimum () const
 Gets the box minimum corner point. More...
 
const VectorTypeMaximum () const
 Gets the box maximum corner point. More...
 
CornerArrayType Corners () const
 Gets the corner points of the box. More...
 
bool Contains (const VectorType &point, T epsilon=T()) const
 Tests whether the box contains a point. More...
 
bool Contains (const AlignedBox &box) const
 Tests whether the box contains another box. More...
 
bool Intersects (const AlignedBox &box) const
 Tests whether the box intersects another box. More...
 
VectorType NearestPoint (const VectorType &point) const
 Computes the nearest point on the box to a point. More...
 
ValueType Distance (const VectorType &point) const
 Computes the distance from a point to the box. More...
 
ValueType Distance2 (const VectorType &point) const
 Computes the squared distance from a point to the box. More...
 
bool operator== (const AlignedBox &box) const
 Checks whether two boxes are equal. More...
 
bool operator!= (const AlignedBox &box) const
 Checks whether two boxes are not equal. More...
 

Static Public Attributes

static const unsigned int numCorners = 1 << N
 The number of corners for the box.
 
static const unsigned int dimensions = N
 The box dimensions.
 

Detailed Description

template<typename T, unsigned int N>
class olp::math::AlignedBox< T, N >

The aligned bounding-box implementation.

Template Parameters
TThe real type.
NThe box dimensions.

Constructor & Destructor Documentation

◆ AlignedBox() [1/3]

template<typename T , unsigned int N>
olp::math::AlignedBox< T, N >::AlignedBox

Creates an AlignedBox instance.

An empty box is created.

◆ AlignedBox() [2/3]

template<typename T , unsigned int N>
olp::math::AlignedBox< T, N >::AlignedBox ( const VectorType min,
const VectorType max 
)

Creates an AlignedBox instance.

If any component of min is greater than max, an empty box is created.

Parameters
[in]minThe box minimum point.
[in]maxThe box maximum point.

◆ AlignedBox() [3/3]

template<typename T , unsigned int N>
template<typename OtherT >
olp::math::AlignedBox< T, N >::AlignedBox ( const AlignedBox< OtherT, N > &  other)

Creates a copy of the AlignedBox instance.

Template Parameters
OtherTThe real type of the box being copied.
Parameters
[in]otherThe box to be copied.

Member Function Documentation

◆ Center()

template<typename T , unsigned int N>
AlignedBox< T, N >::VectorType olp::math::AlignedBox< T, N >::Center

Gets the center point of the box.

The center of an empty box is undefined.

Returns
The box center point.

◆ Contains() [1/2]

template<typename T , unsigned int N>
bool olp::math::AlignedBox< T, N >::Contains ( const AlignedBox< T, N > &  box) const

Tests whether the box contains another box.

Parameters
[in]boxThe aligned box.
Returns
True if the box contains another box; false otherwise.

◆ Contains() [2/2]

template<typename T , unsigned int N>
bool olp::math::AlignedBox< T, N >::Contains ( const VectorType point,
epsilon = T() 
) const

Tests whether the box contains a point.

This test is inclusive.

Parameters
pointThe point to be tested.
epsilonThe epsilon around the point.
Returns
True if the box contains the point; false otherwise.

◆ Corners()

template<typename T , unsigned int N>
CornerArrayType olp::math::AlignedBox< T, N >::Corners ( ) const

Gets the corner points of the box.

The corner points of an empty box are undefined.

Returns
An array containing the box corner points.

◆ Distance()

template<typename T , unsigned int N>
auto olp::math::AlignedBox< T, N >::Distance ( const VectorType point) const

Computes the distance from a point to the box.

A point on or inside the box has a distance of zero.

The distance to an empty box is undefined.

Parameters
[in]pointThe point from which to find the distance.
Returns
The distance between the point and the box.

◆ Distance2()

template<typename T , unsigned int N>
auto olp::math::AlignedBox< T, N >::Distance2 ( const VectorType point) const

Computes the squared distance from a point to the box.

A point on or inside the box has a squared distance of zero.

The squared distance to an empty box is undefined.

Parameters
[in]pointThe point from which to find the squared distance.
Returns
The squared distance between the point and the box.

◆ Empty()

template<typename T , unsigned int N>
bool olp::math::AlignedBox< T, N >::Empty

Tests whether the box is empty.

Returns
True if the box is empty; false otherwise.

◆ Intersects()

template<typename T , unsigned int N>
bool olp::math::AlignedBox< T, N >::Intersects ( const AlignedBox< T, N > &  box) const

Tests whether the box intersects another box.

A test box is considered to be intersecting if another box contains it.

Parameters
[in]boxThe box to be tested.
Returns
True if the boxes intersect; false otherwise.

◆ Maximum()

template<typename T , unsigned int N>
const AlignedBox< T, N >::VectorType & olp::math::AlignedBox< T, N >::Maximum

Gets the box maximum corner point.

The maximum corner point of an empty box is undefined.

Returns
The maximum point of the box.

◆ Minimum()

template<typename T , unsigned int N>
const AlignedBox< T, N >::VectorType & olp::math::AlignedBox< T, N >::Minimum

Gets the box minimum corner point.

The minimum corner point of an empty box is undefined.

Returns
The minimum point of the box.

◆ NearestPoint()

template<typename T , unsigned int N>
VectorType olp::math::AlignedBox< T, N >::NearestPoint ( const VectorType point) const

Computes the nearest point on the box to a point.

The nearest point to an empty box is undefined.

Parameters
[in]pointThe point from which to find the nearest point.
Returns
The nearest point on the box to the specified point.

◆ operator!=()

template<typename T , unsigned int N>
bool olp::math::AlignedBox< T, N >::operator!= ( const AlignedBox< T, N > &  box) const

Checks whether two boxes are not equal.

Parameters
[in]boxThe other box.

◆ operator==()

template<typename T , unsigned int N>
bool olp::math::AlignedBox< T, N >::operator== ( const AlignedBox< T, N > &  box) const

Checks whether two boxes are equal.

Parameters
[in]boxThe other box.

◆ Reset()

template<typename T , unsigned int N>
void olp::math::AlignedBox< T, N >::Reset ( const VectorType min,
const VectorType max 
)

Resets the box to the new minimum and maximum points.

If any component of min is greater than max, an empty box is created.

Parameters
[in]minThe box minimum point.
[in]maxThe box maximum point.

◆ Size()

template<typename T , unsigned int N>
AlignedBox< T, N >::VectorType olp::math::AlignedBox< T, N >::Size

Gets the size of the box.

The size of an empty box is zero.

Returns
The size of each dimension.
Note
An overflow might happen. For example, when max is INT_MAX and min is INT_MIN.

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