geomc 1.0
A c++ linear algebra template library
Loading...
Searching...
No Matches
SphericalHarmonics< T, Bands > Class Template Reference

Class and methods for representing band-limited functions on the surface of a 3D sphere. More...

#include <geomc/function/SphericalHarmonics.h>

Public Member Functions

 SphericalHarmonics ()
 
template<index_t B>
 SphericalHarmonics (const ZonalHarmonics< T, B > &zh)
 
template<index_t B>
 SphericalHarmonics (const ZonalHarmonics< T, B > &zh, Vec< T, 3 > new_axis)
 
 SphericalHarmonics (index_t bands)
 
index_t bands () const
 
void clear ()
 
T & coeff (index_t l, index_t m)
 
coeff (index_t l, index_t m) const
 
template<index_t ZH_Bands>
void convolve (const ZonalHarmonics< T, ZH_Bands > &zh)
 
dot (const SphericalHarmonics< T, Bands > &other) const
 
eval (T alt, T azi) const
 
eval (Vec< T, 3 > d) const
 
T * get ()
 
const T * get () const
 
void normalize ()
 
SphericalHarmonics< T, Bands > & operator*= (T k)
 
SphericalHarmonics< T, Bands > operator+ (const SphericalHarmonics< T, Bands > &sh)
 
SphericalHarmonics< T, Bands > & operator+= (const SphericalHarmonics< T, Bands > &sh)
 
SphericalHarmonics< T, Bands > & operator+= (T k)
 
SphericalHarmonics< T, Bands > & operator- ()
 
SphericalHarmonics< T, Bands > & operator/= (T k)
 
void project (T alt, T azi, T val)
 
void project (Vec< T, 3 > d, T val)
 
index_t size () const
 

Static Public Member Functions

static SphericalHarmonics< T, Bands > basis (Vec< T, 3 > d, index_t n=Bands)
 Construct a SphericalHarmonics basis for the direction given by d.
 

Public Attributes

UniqueStorage< T, Bands *Bands > coeffs
 Coefficient vector.
 

Protected Member Functions

_eval (T cos_alt, T azi) const
 
void _project (T cos_alt, T azi, T val)
 

Protected Attributes

Dimension< Bands >::storage_t n_bands
 

Detailed Description

template<typename T, index_t Bands>
class geom::SphericalHarmonics< T, Bands >

Class and methods for representing band-limited functions on the surface of a 3D sphere.

Template Parameters
TType of evaluated function.
BandsNumber of bands to represent, or 0 if the band count is dynamic.

Memory requirements are O(n2) on the number of bands.

This implementation uses the Condon-Shortley phase convention.

Complex-valued SH functions are not yet natively supported.

Constructor & Destructor Documentation

◆ SphericalHarmonics() [1/4]

template<typename T, index_t Bands>
SphericalHarmonics ( )
inline

Construct a new SphericalHarmonics.

If dynamically sized, only a single DC band will be allocated.

◆ SphericalHarmonics() [2/4]

template<typename T, index_t Bands>
SphericalHarmonics ( index_t bands)
inlineexplicit

Construct a new SphericalHarmonics. (Dynamic size).

Parameters
bandsNumber of bands to represent. Ignored unless the template parameter Bands is 0 (dynamic).

◆ SphericalHarmonics() [3/4]

template<typename T, index_t Bands>
template<index_t B>
SphericalHarmonics ( const ZonalHarmonics< T, B > & zh)
inline

Construct a new SphericalHarmonics matching the function described by the given ZonalHarmonics.

◆ SphericalHarmonics() [4/4]

template<typename T, index_t Bands>
template<index_t B>
SphericalHarmonics ( const ZonalHarmonics< T, B > & zh,
Vec< T, 3 > new_axis )
inline

Construct a new SphericalHarmonics matching the given ZonalHarmonics, re-oriented so that the axis of symmetry aligns with new_axis.

Parameters
zhZonalHarmonics funciton.
new_axisNew axis of rotational symmetry.

Member Function Documentation

◆ bands()

template<typename T, index_t Bands>
index_t bands ( ) const
inline
Returns
Number of bands stored.

◆ basis()

template<typename T, index_t Bands>
static SphericalHarmonics< T, Bands > basis ( Vec< T, 3 > d,
index_t n = Bands )
inlinestatic

Construct a SphericalHarmonics basis for the direction given by d.

Parameters
dDirection for basis.
nNumber of bands to use, if dynamic.

◆ clear()

template<typename T, index_t Bands>
void clear ( )
inline

Set all coefficients to zero.

◆ coeff() [1/2]

template<typename T, index_t Bands>
T & coeff ( index_t l,
index_t m )
inline

Get the stored SH coefficient for band l and sub-band m.

Parameters
lInteger in [0, bands()).
mInteger in [-l, l].

◆ coeff() [2/2]

template<typename T, index_t Bands>
T coeff ( index_t l,
index_t m ) const
inline

Get the stored SH coefficient for band l and sub-band m.

Parameters
lInteger in [0, bands()).
mInteger in [-l, l].

◆ convolve()

template<typename T, index_t Bands>
template<index_t ZH_Bands>
void convolve ( const ZonalHarmonics< T, ZH_Bands > & zh)
inline

Convolve this SphericalHarmonics with a point spread function described by zh.

Parameters
zhPoint spread (kernel) function.

◆ dot()

template<typename T, index_t Bands>
T dot ( const SphericalHarmonics< T, Bands > & other) const
inline

Compute the inner product of this SH function with other.

Returns
Sum of products of respective coefficients between this and other.

◆ eval() [1/2]

template<typename T, index_t Bands>
T eval ( T alt,
T azi ) const
inline

Evaluate this SphericalHarmonics function in the direction described by alt and azi.

Parameters
altAngle from the polar axis.
aziAzimuthal (longitude) angle.
Returns
Reconstructed function value.

◆ eval() [2/2]

template<typename T, index_t Bands>
T eval ( Vec< T, 3 > d) const
inline

Evaluate this SphericalHarmonics function in given direction. The polar direction is aligned with z+, and the x-axis has zero azimuthal angle.

Parameters
dDirection along which to sample the funciton.
Returns
Reconstructed function value.

◆ get() [1/2]

template<typename T, index_t Bands>
T * get ( )
inline

Get a pointer to the array of coefficients.

◆ get() [2/2]

template<typename T, index_t Bands>
const T * get ( ) const
inline

Get a pointer to the array of coefficients.

◆ normalize()

template<typename T, index_t Bands>
void normalize ( )
inline

Ensure the integral over the entire sphere is 1. If the integral is currently 0, no change will be made.

◆ operator*=()

template<typename T, index_t Bands>
SphericalHarmonics< T, Bands > & operator*= ( T k)
inline

Multiply this SphericalHarmonics function by a constant value.

Parameters
kGain factor.

◆ operator+()

template<typename T, index_t Bands>
SphericalHarmonics< T, Bands > operator+ ( const SphericalHarmonics< T, Bands > & sh)
inline

Construct a SphericalHarmonics function which is the sum of this and another.

◆ operator+=() [1/2]

template<typename T, index_t Bands>
SphericalHarmonics< T, Bands > & operator+= ( const SphericalHarmonics< T, Bands > & sh)
inline

Add another SphericalHarmonics function to this one.

◆ operator+=() [2/2]

template<typename T, index_t Bands>
SphericalHarmonics< T, Bands > & operator+= ( T k)
inline

Add a constant value to this SphericalHarmonics function.

Parameters
kBias.

◆ operator-()

template<typename T, index_t Bands>
SphericalHarmonics< T, Bands > & operator- ( )
inline

Negate the values of this SphericalHarmonics function.

◆ operator/=()

template<typename T, index_t Bands>
SphericalHarmonics< T, Bands > & operator/= ( T k)
inline

Divide this SphericalHarmonics function by a constant value.

Parameters
kDivisor.

◆ project() [1/2]

template<typename T, index_t Bands>
void project ( T alt,
T azi,
T val )
inline

Project the Dirac delta function with direction given by alt and azi, and integral val onto the spherical harmonic basis. The projection will be added to the current representation. In other words, "add" the supplied sample to the representation.

To represent a known function on the sphere, draw many samples from it and project each sample, then divide by the number of samples.

Parameters
dDirection of sample to project.
valValue of sample.

◆ project() [2/2]

template<typename T, index_t Bands>
void project ( Vec< T, 3 > d,
T val )
inline

Project the Dirac delta function with direction d and integral val onto the spherical harmonic basis. The projection will be added to the current representation. In other words, "add" the supplied sample to the representation.

To represent a known function on the sphere, draw many samples from it and project each sample, then divide by 4π times the number of samples.

Parameters
altAngle from the polar axis.
aziAzimuthal (longitude) angle.
valValue of sample.

◆ size()

template<typename T, index_t Bands>
index_t size ( ) const
inline
Returns
Number of coefficients stored.

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