RobWorkProject  23.9.11-
Public Types | Public Member Functions | List of all members
HyperSphere Class Reference

A hyper-sphere of K dimensions. More...

#include <HyperSphere.hpp>

Public Types

typedef rw::core::Ptr< const HyperSpherePtr
 Smart pointer type for HyperSphere.
 

Public Member Functions

 HyperSphere (unsigned int dimensions)
 Construct a hyper-sphere of unit size. More...
 
virtual ~HyperSphere ()
 Destructor.
 
std::vector< Eigen::VectorXd > uniformDistributionCartesian (double delta) const
 Create a uniform distribution in Cartesian coordinates. More...
 
std::vector< Eigen::VectorXd > uniformDistributionSpherical (double delta) const
 Create a uniform distribution in spherical coordinates. More...
 
unsigned int getDimensions () const
 Get the number of dimensions of the hyper-sphere. More...
 
double area () const
 Calculate the surface area of a hyper-sphere. More...
 
double volume () const
 The volume of a hyper-sphere. More...
 

Detailed Description

A hyper-sphere of K dimensions.

Functions are provided to create (almost) uniform distribution of points on a hyper-sphere as shown in [1].

The distribution of points is illustrated below for 2 and 3 dimensional hyper-spheres. Notice that the tessellation is best when \( \delta\) is small.

Distribution of points for K=2 and K=3.

[1] Lovisolo, L., and E. A. B. Da Silva. "Uniform distribution of points on a hyper-sphere with applications to vector bit-plane encoding." IEE Proceedings-Vision, Image and Signal Processing 148.3 (2001): 187-193.

Constructor & Destructor Documentation

◆ HyperSphere()

HyperSphere ( unsigned int  dimensions)

Construct a hyper-sphere of unit size.

Parameters
dimensions[in] the number of dimensions.

Member Function Documentation

◆ area()

double area ( ) const

Calculate the surface area of a hyper-sphere.

Calculated for even dimensionality as \( \frac{K \pi^{K/2}}{(K/2)!}\)

Calculated for odd dimensionality as \( \frac{K 2^K \pi^{(K-1)/2}}{K!}\)

Returns
the surface area.

◆ getDimensions()

unsigned int getDimensions ( ) const

Get the number of dimensions of the hyper-sphere.

Returns
the number of dimensions, \( 2 \leq K \leq 6\) .

◆ uniformDistributionCartesian()

std::vector<Eigen::VectorXd> uniformDistributionCartesian ( double  delta) const

Create a uniform distribution in Cartesian coordinates.

This uses uniformDistributionSpherical and maps the spherical coordinates to Cartesian coordinates. The mapping is documented in [1], section 2.1.

Parameters
delta[in] the resolution.
Returns
unit vectors, \( [x_1 x_2 \dots x_K]^T\) , in Cartesian coordinates with dimension K.
Note
This function is only implemented for \( 2 \leq K \leq 6\) .

◆ uniformDistributionSpherical()

std::vector<Eigen::VectorXd> uniformDistributionSpherical ( double  delta) const

Create a uniform distribution in spherical coordinates.

This implements the algorithm in [1], section 2.1, for dimensions \( 2 \leq K \leq 6\).

Parameters
delta[in] the resolution.
Returns
list of vectors, \( [\theta_1 \theta_2 \dots \theta_{K-1}]^T\) , in spherical coordinates with dimension K-1.
Note
This function is only implemented for \( 2 \leq K \leq 6\) .

◆ volume()

double volume ( ) const

The volume of a hyper-sphere.

Calculated for even dimensionality as \( \frac{\pi^{K/2}}{(K/2)!}\)

Calculated for odd dimensionality as \( \frac{2 (2 \pi)^{(K-1)/2}}{K!!}\) where the double factorial for odd K means \( 1 \cdot 3 \cdot 5 \dots K\)

Returns
the volume.

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