geomc 1.0
A c++ linear algebra template library
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
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 ()
 
 SphericalHarmonics (index_t bands)
 
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)
 
coeff (index_t l, index_t m) const
 
T & coeff (index_t l, index_t m)
 
T * get ()
 
const T * get () const
 
index_t size () const
 
index_t bands () const
 
dot (const SphericalHarmonics< T, Bands > &other) const
 
void normalize ()
 
template<index_t ZH_Bands>
void convolve (const ZonalHarmonics< T, ZH_Bands > &zh)
 
eval (Vec< T, 3 > d) const
 
eval (T alt, T azi) const
 
void project (Vec< T, 3 > d, T val)
 
void project (T alt, T azi, T val)
 
void clear ()
 
SphericalHarmonics< T, Bands > & operator- ()
 
SphericalHarmonics< T, Bands > & operator*= (T k)
 
SphericalHarmonics< T, Bands > & operator/= (T k)
 
SphericalHarmonics< T, Bands > & operator+= (T k)
 
SphericalHarmonics< T, Bands > & operator+= (const SphericalHarmonics< T, Bands > &sh)
 
SphericalHarmonics< T, Bands > operator+ (const SphericalHarmonics< T, Bands > &sh)
 

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

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]

SphericalHarmonics ( )
inline

Construct a new SphericalHarmonics.

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

◆ SphericalHarmonics() [2/4]

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]

SphericalHarmonics ( const ZonalHarmonics< T, B > &  zh)
inline

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

◆ SphericalHarmonics() [4/4]

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()

index_t bands ( ) const
inline
Returns
Number of bands stored.

◆ basis()

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()

void clear ( )
inline

Set all coefficients to zero.

◆ coeff() [1/2]

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]

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()

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()

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]

T eval ( alt,
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]

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]

T * get ( )
inline

Get a pointer to the array of coefficients.

◆ get() [2/2]

const T * get ( ) const
inline

Get a pointer to the array of coefficients.

◆ normalize()

void normalize ( )
inline

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

◆ operator*=()

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

Multiply this SphericalHarmonics function by a constant value.

Parameters
kGain factor.

◆ operator+()

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]

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

Add another SphericalHarmonics function to this one.

◆ operator+=() [2/2]

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

Add a constant value to this SphericalHarmonics function.

Parameters
kBias.

◆ operator-()

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

Negate the values of this SphericalHarmonics function.

◆ operator/=()

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

Divide this SphericalHarmonics function by a constant value.

Parameters
kDivisor.

◆ project() [1/2]

void project ( alt,
azi,
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]

void project ( Vec< T, 3 >  d,
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()

index_t size ( ) const
inline
Returns
Number of coefficients stored.

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