From 0414cbc2f3a92c59aab6b762ff15951cf224a3e3 Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Wed, 29 Oct 2008 15:26:45 +0000 Subject: [PATCH] Fixed includes, new interface to specify polar functions --- vcg/math/spherical_harmonics.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/vcg/math/spherical_harmonics.h b/vcg/math/spherical_harmonics.h index bae8f16a..f2436d99 100644 --- a/vcg/math/spherical_harmonics.h +++ b/vcg/math/spherical_harmonics.h @@ -26,21 +26,27 @@ #include -#include "vcg/math/base.h" -#include "vcg/math/random_generator.h" -#include "vcg/math/legendre.h" -#include "vcg/math/factorial.h" +#include +#include +#include +#include namespace vcg{ namespace math{ +template +class PolarFunctor{ + public: + virtual ScalarType operator()(ScalarType theta, ScalarType phi) = 0; +}; + /** * Although the Real Spherical Harmonic Function is correctly defined over any * 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 * for positive m only. */ -template +template class SphericalHarmonics{ private : @@ -83,9 +89,7 @@ public : else return SQRT_TWO * complex_spherical_harmonic_im(l, -m, theta, phi); } - typedef ScalarType (*PolarFunction) (ScalarType theta, ScalarType phi); - - static SphericalHarmonics Project(PolarFunction fun, unsigned n_samples) + static SphericalHarmonics Project(PolarFunctor * fun, unsigned n_samples) { const ScalarType weight = 4 * M_PI; @@ -117,7 +121,7 @@ public : for (int m = -l; m <= l; ++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++;