Fixed includes, new interface to specify polar functions
This commit is contained in:
parent
c8506daaff
commit
0414cbc2f3
|
|
@ -26,21 +26,27 @@
|
||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
||||||
#include "vcg/math/base.h"
|
#include <vcg/math/base.h>
|
||||||
#include "vcg/math/random_generator.h"
|
#include <vcg/math/random_generator.h>
|
||||||
#include "vcg/math/legendre.h"
|
#include <vcg/math/legendre.h>
|
||||||
#include "vcg/math/factorial.h"
|
#include <vcg/math/factorial.h>
|
||||||
|
|
||||||
namespace vcg{
|
namespace vcg{
|
||||||
namespace math{
|
namespace math{
|
||||||
|
|
||||||
|
template <typename ScalarType>
|
||||||
|
class PolarFunctor{
|
||||||
|
public:
|
||||||
|
virtual ScalarType operator()(ScalarType theta, ScalarType phi) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Although the Real Spherical Harmonic Function is correctly defined over any
|
* Although the Real Spherical Harmonic Function is correctly defined over any
|
||||||
* positive l and any -l <= m <= l, the two internal functions computing the
|
* positive l and any -l <= m <= l, the two internal functions computing the
|
||||||
* imaginary and real parts of the Complex Spherical Harmonic Functions are defined
|
* imaginary and real parts of the Complex Spherical Harmonic Functions are defined
|
||||||
* for positive m only.
|
* for positive m only.
|
||||||
*/
|
*/
|
||||||
template <typename ScalarType, int MAX_BAND>
|
template <typename ScalarType, int MAX_BAND = 4>
|
||||||
class SphericalHarmonics{
|
class SphericalHarmonics{
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
@ -83,9 +89,7 @@ public :
|
||||||
else return SQRT_TWO * complex_spherical_harmonic_im(l, -m, theta, phi);
|
else return SQRT_TWO * complex_spherical_harmonic_im(l, -m, theta, phi);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef ScalarType (*PolarFunction) (ScalarType theta, ScalarType phi);
|
static SphericalHarmonics Project(PolarFunctor<ScalarType> * fun, unsigned n_samples)
|
||||||
|
|
||||||
static SphericalHarmonics Project(PolarFunction fun, unsigned n_samples)
|
|
||||||
{
|
{
|
||||||
const ScalarType weight = 4 * M_PI;
|
const ScalarType weight = 4 * M_PI;
|
||||||
|
|
||||||
|
|
@ -117,7 +121,7 @@ public :
|
||||||
for (int m = -l; m <= l; ++m)
|
for (int m = -l; m <= l; ++m)
|
||||||
{
|
{
|
||||||
int index = l * (l+1) + m;
|
int index = l * (l+1) + m;
|
||||||
sph.coefficients[index] += fun(theta, phi) * Real(l, m, theta, phi);
|
sph.coefficients[index] += (*fun)(theta, phi) * Real(l, m, theta, phi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue