GeographicLib: GeographicLib::CircularEngine Class Reference (original) (raw)
Spherical harmonic sums for a circle.
The class is a companion to SphericalEngine. If the results of a spherical harmonic sum are needed for several points on a circle of constant latitude lat and height h, then SphericalEngine::Circle can compute the inner sum, which is independent of longitude lon, and produce a CircularEngine object. CircularEngine::operator()() can then be used to perform the outer sum for particular vales of lon. This can lead to substantial improvements in computational speed for high degree sum (approximately by a factor of N / 2 where N is the maximum degree).
CircularEngine is tightly linked to the internals of SphericalEngine. For that reason, the constructor for this class is private. Use SphericalHarmonic::Circle, SphericalHarmonic1::Circle, and SphericalHarmonic2::Circle to create instances of this class.
CircularEngine stores the coefficients needed to allow the summation over order to be performed in 2 or 6 vectors of length M + 1 (depending on whether gradients are to be calculated). For this reason the constructor may throw a std::bad_alloc exception.
Example of use:
#include
#include
#include
using namespace std;
try {
using std::hypot;
int N = 3;
double ca[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
vector C(ca, ca + (N + 1) * (N + 2) / 2);
double sa[] = {6, 5, 4, 3, 2, 1};
vector S(sa, sa + N * (N + 1) / 2);
double a = 1;
double x = 2, y = 3, z = 1, p = hypot(x, y);
double v, vx, vy, vz;
v = circ(x/p, y/p, vx, vy, vz);
cout << v << " " << vx << " " << vy << " " << vz << "\n";
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
int main(int argc, const char *const argv[])
Header for GeographicLib::CircularEngine class.
Header for GeographicLib::SphericalHarmonic class.
Spherical harmonic sums for a circle.
Spherical harmonic series.
Namespace for GeographicLib.
Definition at line 52 of file CircularEngine.hpp.