PPL API Reference
Overview Core Algorithm Abstractions Utilities Parallel Methods
Modules Class Hierarchy Classes Functions
Todo List Bug List Dead Code
List of all members | Friends
NBox Class Reference

An axis-aligned rectangular prism in n dimensions. More...

Public Member Functions

Construction
 NBox (const size_t _n)
 
 NBox (const std::vector< double > &_center)
 
virtual ~NBox () noexcept
 
Accessors
size_t GetDimension () const noexcept
 Get the dimension of this box.
 
void SetCenter (const std::vector< double > &_c) noexcept
 Set the center point.
 
const std::vector< double > & GetCenter () const noexcept
 Get the center point.
 
const Range< double > & GetRange (const size_t _i) const noexcept
 
const std::vector< Range< double > > & GetRanges () const noexcept
 Get all of the ranges.
 
void SetRange (const size_t _i, const Range< double > &_r) noexcept
 
void SetRange (const size_t _i, Range< double > &&_r) noexcept
 
void SetRange (const size_t _i, const double _min, const double _max) noexcept
 
void Translate (const std::vector< double > &_v) noexcept
 
double GetVolume () const noexcept
 Compute the (hyper)volume or Lebesgue measure.
 
Point Testing

If the box and point have different dimensions, the missing values will be assumed to be 0.

bool Contains (const std::vector< double > &_p) const noexcept
 
double Clearance (const std::vector< double > &_p) const noexcept
 
std::vector< double > ClearancePoint (std::vector< double > _p) const noexcept
 
Sampling
std::vector< double > Sample () const
 Sample a random point in the box with uniform probability.
 

Friends

std::istream & operator>> (std::istream &_is, NBox &_box)
 

Detailed Description

An axis-aligned rectangular prism in n dimensions.

Constructor & Destructor Documentation

◆ NBox() [1/2]

NBox::NBox ( const size_t  _n)
explicit

Construct an infinite box centered at the origin in _n dimensions.

Parameters
_nThe number of dimensions.

◆ NBox() [2/2]

NBox::NBox ( const std::vector< double > &  _center)
explicit

Construct an infinite box with a designated center point.

Parameters
_centerThe center point, which is assumed to be of full dimension.

Member Function Documentation

◆ GetRange()

const Range< double > & NBox::GetRange ( const size_t  _i) const
noexcept

Get a range in a given dimension.

Parameters
_iThe dimension index.
Returns
The range of this volume in dimension _i.

◆ SetRange() [1/2]

void NBox::SetRange ( const size_t  _i,
const Range< double > &  _r 
)
noexcept

Set the range in a given dimension.

Parameters
_iThe dimension index.
_rThe new range to use.

◆ SetRange() [2/2]

void NBox::SetRange ( const size_t  _i,
const double  _min,
const double  _max 
)
noexcept

Set the range in a given dimension.

Parameters
_iThe dimension index.
_minThe new lower bound.
_maxThe new upper bound.

◆ Translate()

void NBox::Translate ( const std::vector< double > &  _v)
noexcept

Translate the entire n-box.

Parameters
_vThe translation vector to apply. If it has fewer dimensions than the NBox, it will be applied to the first (_v.size()) dimensions of this.

◆ Contains()

bool NBox::Contains ( const std::vector< double > &  _p) const
noexcept

Test if a given point lies within the box.

Parameters
_pThe point to test.
Returns
True if _p lies within the box.

◆ Clearance()

double NBox::Clearance ( const std::vector< double > &  _p) const
noexcept

Compute the minimum distance to the box's surface from a given point. This is bounding-box style, so clearance is positive if the point is inside the box and negative if it is outside.

Parameters
_pThe point of interest.
Returns
The minimum distance from _p to the box's surface.

◆ ClearancePoint()

std::vector< double > NBox::ClearancePoint ( std::vector< double >  _p) const
noexcept

Find the point on the box that is nearest to a given reference point.

Parameters
_pThe reference point.
Returns
The point on the surface that is nearest to _p.

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