Spherical Harmonics are templatized on the number of coefficients
This commit is contained in:
parent
2da37bd5f7
commit
39e2cf2b3e
|
@ -40,7 +40,7 @@ namespace math{
|
|||
* imaginary and real parts of the Complex Spherical Harmonic Functions are defined
|
||||
* for positive m only.
|
||||
*/
|
||||
template <typename ScalarType>
|
||||
template <typename ScalarType, int MAX_BAND>
|
||||
class SphericalHarmonics{
|
||||
|
||||
private :
|
||||
|
@ -59,8 +59,8 @@ private :
|
|||
return scaling_factor(l, m) * Legendre<ScalarType>::AssociatedPolynomial(l, m, Cos(theta), Sin(theta)) * Sin(m * phi);
|
||||
}
|
||||
|
||||
ScalarType * coefficients;
|
||||
int max_band;
|
||||
ScalarType coefficients[MAX_BAND * MAX_BAND];
|
||||
static const int max_band = MAX_BAND;
|
||||
|
||||
public :
|
||||
|
||||
|
@ -85,22 +85,19 @@ public :
|
|||
|
||||
typedef ScalarType (*PolarFunction) (ScalarType theta, ScalarType phi);
|
||||
|
||||
static SphericalHarmonics Project(PolarFunction fun, unsigned max_band, unsigned n_samples)
|
||||
static SphericalHarmonics Project(PolarFunction fun, unsigned n_samples)
|
||||
{
|
||||
const ScalarType weight = 4 * M_PI;
|
||||
|
||||
unsigned sqrt_n_samples = (unsigned int) Sqrt((int)n_samples);
|
||||
unsigned actual_n_samples = sqrt_n_samples * sqrt_n_samples;
|
||||
unsigned n_coeff = max_band * max_band;
|
||||
unsigned n_coeff = MAX_BAND * MAX_BAND;
|
||||
|
||||
ScalarType one_over_n = 1.0/(ScalarType)sqrt_n_samples;
|
||||
|
||||
RandomGenerator rand;
|
||||
SphericalHarmonics sph;
|
||||
|
||||
sph.coefficients = new ScalarType[n_coeff];
|
||||
sph.max_band = max_band;
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (unsigned k = 0; k < n_coeff; k++ ) sph.coefficients[k] = 0;
|
||||
|
|
Loading…
Reference in New Issue