Parasol Planning Library (PPL)
Friends
NSphere Class Reference

#include <NSphere.h>

Inheritance diagram for NSphere:
Inheritance graph
[legend]

Public Member Functions

Construction
 NSphere (const size_t _n, const double _r=std::numeric_limits< double >::max())
 
 NSphere (const std::vector< double > &_center, const double _r=std::numeric_limits< double >::max())
 
virtual ~NSphere () noexcept
 
Accessors
size_t GetDimension () const noexcept
 Get the dimension of this sphere. More...
 
void SetCenter (const std::vector< double > &_c) noexcept
 
const std::vector< double > & GetCenter () const noexcept
 Get the center point. More...
 
double GetRadius () const noexcept
 Get the radius. More...
 
void SetRadius (const double _r) noexcept
 Set the radius. More...
 
void Translate (const std::vector< double > &_v) noexcept
 
double GetVolume () const noexcept
 Compute the (hyper)volume or Lebesgue measure. More...
 
Point Testing

If the sphere 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 (std::vector< double > _p) const noexcept
 
std::vector< double > ClearancePoint (std::vector< double > _p) const noexcept
 
Sampling
std::vector< double > Sample () const
 

Friends

std::istream & operator>> (std::istream &_is, NSphere &_sphere)
 

Detailed Description

A general representation of a spherical volume in N dimensions.

This object also models the inscribed hyper-volume, so the proper formal name for it is an 'N-ball'. I.e., setting N = 3 creates a (two-)sphere in R^3 plus the inscribed volume. See wikipedia's article on n-sphere for further clarification.

Constructor & Destructor Documentation

◆ NSphere() [1/2]

NSphere::NSphere ( const size_t  _n,
const double  _r = std::numeric_limits<double>::max() 
)
explicit

Construct an n-sphere at the origin with a given dimension and radius.

Parameters
_nThe dimension of the n-sphere.
_rThe sphere radius (infinite by default).

◆ NSphere() [2/2]

NSphere::NSphere ( const std::vector< double > &  _center,
const double  _r = std::numeric_limits<double>::max() 
)
explicit

Construct an n-sphere with a given center point and radius.

Parameters
_cThe center point of the n-sphere, which is assumed to be of full dimension.
_rThe sphere radius (infinite by default).

◆ ~NSphere()

NSphere::~NSphere ( )
virtualdefaultnoexcept

Member Function Documentation

◆ Clearance()

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

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

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

◆ ClearancePoint()

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

Find the point on the sphere 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 NSphere::Contains ( const std::vector< double > &  _p) const
noexcept

Test if a given point lies within the n-sphere.

Parameters
_pThe point to test.
Returns
True if _p lies within the n-sphere.

◆ GetCenter()

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

Get the center point.

◆ GetDimension()

size_t NSphere::GetDimension ( ) const
noexcept

Get the dimension of this sphere.

◆ GetRadius()

double NSphere::GetRadius ( ) const
noexcept

Get the radius.

◆ GetVolume()

double NSphere::GetVolume ( ) const
noexcept

Compute the (hyper)volume or Lebesgue measure.

◆ Sample()

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

Sample a random point in the n-sphere with uniform probability via the Muller/Marsaglia method.

◆ SetCenter()

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

Set the center point.

Parameters
_cThe new center point.

◆ SetRadius()

void NSphere::SetRadius ( const double  _r)
noexcept

Set the radius.

◆ Translate()

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

Translate the entire n-sphere.

Parameters
_vThe translation vector to apply.

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  _is,
NSphere _sphere 
)
friend

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