Parasol Planning Library (PPL)
Friends
NBox Class Reference

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

#include <NBox.h>

Inheritance diagram for NBox:
Inheritance graph
[legend]

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. More...
 
void SetCenter (const std::vector< double > &_c) noexcept
 Set the center point. More...
 
const std::vector< double > & GetCenter () const noexcept
 Get the center point. More...
 
const Range< double > & GetRange (const size_t _i) const noexcept
 
const std::vector< Range< double > > & GetRanges () const noexcept
 Get all of the ranges. More...
 
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. More...
 
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. More...
 

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.

◆ ~NBox()

NBox::~NBox ( )
virtualdefaultnoexcept

Member Function Documentation

◆ 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.

◆ 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.

◆ GetCenter()

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

Get the center point.

◆ GetDimension()

size_t NBox::GetDimension ( ) const
noexcept

Get the dimension of this box.

◆ 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.

◆ GetRanges()

const std::vector< Range< double > > & NBox::GetRanges ( ) const
noexcept

Get all of the ranges.

◆ GetVolume()

double NBox::GetVolume ( ) const
noexcept

Compute the (hyper)volume or Lebesgue measure.

◆ Sample()

std::vector< double > NBox::Sample ( ) const

Sample a random point in the box with uniform probability.

◆ SetCenter()

void NBox::SetCenter ( const std::vector< double > &  _c)
noexcept

Set the center point.

◆ SetRange() [1/3]

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.

◆ SetRange() [2/3]

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() [3/3]

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

◆ 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.

Friends And Related Function Documentation

◆ operator>>

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

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