/** * @return a point sample of a Spherical Harmonic basis function * l is the band, range [0..N] * m in the range [-l..l] * theta in the range [0..Pi] * phi in the range [0..2*Pi] */ double SphericalHarmonics::SH(int l, int m, double theta, double phi) { const double sqrt2 = sqrt(2.0); if(m==0) return K(l,0)*P(l,m,cos(theta)); else if(m>0) return sqrt2*K(l,m)*cos(m*phi)*P(l,m,cos(theta)); else return sqrt2*K(l,-m)*sin(-m*phi)*P(l,-m,cos(theta)); }This code, by the way, is part of my Harmoniker app that you can find in github.
Tweet