diff --git a/stim/math/spharmonics.h b/stim/math/spharmonics.h index c51ee91..e6c5a11 100644 --- a/stim/math/spharmonics.h +++ b/stim/math/spharmonics.h @@ -231,6 +231,17 @@ public: return fx; } + + /// Fill an NxN grid with the spherical function for theta = [0 2pi] and phi = [0 pi] + void grid(T* data, size_t N){ + double dt = stim::TAU / (double)N; //calculate the step size in each direction + double dp = stim::PI / (double)(N - 1); + for(size_t ti = 0; ti < N; ti++){ + for(size_t pi = 0; pi < N){ + data[pi * N + ti] = (*this)((double)ti * dt, (double)pi * dp); + } + } + } /* //overload arithmetic operations spharmonics operator*(T rhs) const { -- libgit2 0.21.4