GeographicLib 2.1.2
GeographicLib::SphericalHarmonic2 Class Reference

Spherical harmonic series with two corrections to the coefficients. More...

#include <GeographicLib/SphericalHarmonic2.hpp>

Public Types

enum  normalization { FULL , SCHMIDT }
 

Public Member Functions

 SphericalHarmonic2 (const std::vector< real > &C, const std::vector< real > &S, int N, const std::vector< real > &C1, const std::vector< real > &S1, int N1, const std::vector< real > &C2, const std::vector< real > &S2, int N2, real a, unsigned norm=FULL)
 
 SphericalHarmonic2 (const std::vector< real > &C, const std::vector< real > &S, int N, int nmx, int mmx, const std::vector< real > &C1, const std::vector< real > &S1, int N1, int nmx1, int mmx1, const std::vector< real > &C2, const std::vector< real > &S2, int N2, int nmx2, int mmx2, real a, unsigned norm=FULL)
 
 SphericalHarmonic2 ()
 
Math::real operator() (real tau1, real tau2, real x, real y, real z) const
 
Math::real operator() (real tau1, real tau2, real x, real y, real z, real &gradx, real &grady, real &gradz) const
 
CircularEngine Circle (real tau1, real tau2, real p, real z, bool gradp) const
 
const SphericalEngine::coeffCoefficients () const
 
const SphericalEngine::coeffCoefficients1 () const
 
const SphericalEngine::coeffCoefficients2 () const
 

Detailed Description

Spherical harmonic series with two corrections to the coefficients.

This classes is similar to SphericalHarmonic, except that the coefficients Cnm are replaced by Cnm + tau' C'nm + tau'' C''nm (and similarly for Snm).

Example of use:

// Example of using the GeographicLib::SphericalHarmonic2 class
#include <iostream>
#include <exception>
#include <vector>
using namespace std;
using namespace GeographicLib;
int main() {
try {
int N = 3, N1 = 2, N2 = 1; // The maxium degrees
double ca[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; // cosine coefficients
vector<double> C(ca, ca + (N + 1) * (N + 2) / 2);
double sa[] = {6, 5, 4, 3, 2, 1}; // sine coefficients
vector<double> S(sa, sa + N * (N + 1) / 2);
double cb[] = {1, 2, 3, 4, 5, 6};
vector<double> C1(cb, cb + (N1 + 1) * (N1 + 2) / 2);
double sb[] = {3, 2, 1};
vector<double> S1(sb, sb + N1 * (N1 + 1) / 2);
double cc[] = {2, 1};
vector<double> C2(cc, cc + (N2 + 1));
vector<double> S2;
double a = 1;
SphericalHarmonic2 h(C, S, N, N, N, C1, S1, N1, N1, N1,
C2, S2, N2, N2, 0, a);
double tau1 = 0.1, tau2 = 0.05, x = 2, y = 3, z = 1;
double v, vx, vy, vz;
v = h(tau1, tau2, x, y, z, 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[])
Definition: CartConvert.cpp:29
Header for GeographicLib::SphericalHarmonic2 class.
Spherical harmonic series with two corrections to the coefficients.
Namespace for GeographicLib.
Definition: Accumulator.cpp:12

Definition at line 35 of file SphericalHarmonic2.hpp.

Member Enumeration Documentation

◆ normalization

Supported normalizations for associate Legendre polynomials.

Enumerator
FULL 

Fully normalized associated Legendre polynomials. See SphericalHarmonic::FULL for documentation.

SCHMIDT 

Schmidt semi-normalized associated Legendre polynomials. See SphericalHarmonic::SCHMIDT for documentation.

Definition at line 40 of file SphericalHarmonic2.hpp.

Constructor & Destructor Documentation

◆ SphericalHarmonic2() [1/3]

GeographicLib::SphericalHarmonic2::SphericalHarmonic2 ( const std::vector< real > &  C,
const std::vector< real > &  S,
int  N,
const std::vector< real > &  C1,
const std::vector< real > &  S1,
int  N1,
const std::vector< real > &  C2,
const std::vector< real > &  S2,
int  N2,
real  a,
unsigned  norm = FULL 
)
inline

Constructor with a full set of coefficients specified.

Parameters
[in]Cthe coefficients Cnm.
[in]Sthe coefficients Snm.
[in]Nthe maximum degree and order of the sum
[in]C1the coefficients C'nm.
[in]S1the coefficients S'nm.
[in]N1the maximum degree and order of the first correction coefficients C'nm and S'nm.
[in]C2the coefficients C''nm.
[in]S2the coefficients S''nm.
[in]N2the maximum degree and order of the second correction coefficients C'nm and S'nm.
[in]athe reference radius appearing in the definition of the sum.
[in]normthe normalization for the associated Legendre polynomials, either SphericalHarmonic2::FULL (the default) or SphericalHarmonic2::SCHMIDT.
Exceptions
GeographicErrif N and N1 do not satisfy NN1 ≥ −1, and similarly for N2.
GeographicErrif any of the vectors of coefficients is not large enough.

See SphericalHarmonic for the way the coefficients should be stored. N1 and N2 should satisfy N1N and N2N.

The class stores pointers to the first elements of C, S, C', S', C'', and S''. These arrays should not be altered or destroyed during the lifetime of a SphericalHarmonic object.

Definition at line 97 of file SphericalHarmonic2.hpp.

◆ SphericalHarmonic2() [2/3]

GeographicLib::SphericalHarmonic2::SphericalHarmonic2 ( const std::vector< real > &  C,
const std::vector< real > &  S,
int  N,
int  nmx,
int  mmx,
const std::vector< real > &  C1,
const std::vector< real > &  S1,
int  N1,
int  nmx1,
int  mmx1,
const std::vector< real > &  C2,
const std::vector< real > &  S2,
int  N2,
int  nmx2,
int  mmx2,
real  a,
unsigned  norm = FULL 
)
inline

Constructor with a subset of coefficients specified.

Parameters
[in]Cthe coefficients Cnm.
[in]Sthe coefficients Snm.
[in]Nthe degree used to determine the layout of C and S.
[in]nmxthe maximum degree used in the sum. The sum over n is from 0 thru nmx.
[in]mmxthe maximum order used in the sum. The sum over m is from 0 thru min(n, mmx).
[in]C1the coefficients C'nm.
[in]S1the coefficients S'nm.
[in]N1the degree used to determine the layout of C' and S'.
[in]nmx1the maximum degree used for C' and S'.
[in]mmx1the maximum order used for C' and S'.
[in]C2the coefficients C''nm.
[in]S2the coefficients S''nm.
[in]N2the degree used to determine the layout of C'' and S''.
[in]nmx2the maximum degree used for C'' and S''.
[in]mmx2the maximum order used for C'' and S''.
[in]athe reference radius appearing in the definition of the sum.
[in]normthe normalization for the associated Legendre polynomials, either SphericalHarmonic2::FULL (the default) or SphericalHarmonic2::SCHMIDT.
Exceptions
GeographicErrif the parameters do not satisfy Nnmxmmx ≥ −1; N1nmx1mmx1 ≥ −1; NN1; nmxnmx1; mmxmmx1; and similarly for N2, nmx2, and mmx2.
GeographicErrif any of the vectors of coefficients is not large enough.

The class stores pointers to the first elements of C, S, C', S', C'', and S''. These arrays should not be altered or destroyed during the lifetime of a SphericalHarmonic object.

Definition at line 154 of file SphericalHarmonic2.hpp.

◆ SphericalHarmonic2() [3/3]

GeographicLib::SphericalHarmonic2::SphericalHarmonic2 ( )
inline

A default constructor so that the object can be created when the constructor for another object is initialized. This default object can then be reset with the default copy assignment operator.

Definition at line 180 of file SphericalHarmonic2.hpp.

Member Function Documentation

◆ operator()() [1/2]

Math::real GeographicLib::SphericalHarmonic2::operator() ( real  tau1,
real  tau2,
real  x,
real  y,
real  z 
) const
inline

Compute a spherical harmonic sum with two correction terms.

Parameters
[in]tau1multiplier for correction coefficients C' and S'.
[in]tau2multiplier for correction coefficients C'' and S''.
[in]xcartesian coordinate.
[in]ycartesian coordinate.
[in]zcartesian coordinate.
Returns
V the spherical harmonic sum.

This routine requires constant memory and thus never throws an exception.

Definition at line 196 of file SphericalHarmonic2.hpp.

References FULL, and SCHMIDT.

◆ operator()() [2/2]

Math::real GeographicLib::SphericalHarmonic2::operator() ( real  tau1,
real  tau2,
real  x,
real  y,
real  z,
real &  gradx,
real &  grady,
real &  gradz 
) const
inline

Compute a spherical harmonic sum with two correction terms and its gradient.

Parameters
[in]tau1multiplier for correction coefficients C' and S'.
[in]tau2multiplier for correction coefficients C'' and S''.
[in]xcartesian coordinate.
[in]ycartesian coordinate.
[in]zcartesian coordinate.
[out]gradxx component of the gradient
[out]gradyy component of the gradient
[out]gradzz component of the gradient
Returns
V the spherical harmonic sum.

This is the same as the previous function, except that the components of the gradients of the sum in the x, y, and z directions are computed. This routine requires constant memory and thus never throws an exception.

Definition at line 235 of file SphericalHarmonic2.hpp.

References FULL, and SCHMIDT.

◆ Circle()

CircularEngine GeographicLib::SphericalHarmonic2::Circle ( real  tau1,
real  tau2,
real  p,
real  z,
bool  gradp 
) const
inline

Create a CircularEngine to allow the efficient evaluation of several points on a circle of latitude at fixed values of tau1 and tau2.

Parameters
[in]tau1multiplier for correction coefficients C' and S'.
[in]tau2multiplier for correction coefficients C'' and S''.
[in]pthe radius of the circle.
[in]zthe height of the circle above the equatorial plane.
[in]gradpif true the returned object will be able to compute the gradient of the sum.
Exceptions
std::bad_allocif the memory for the CircularEngine can't be allocated.
Returns
the CircularEngine object.

SphericalHarmonic2::operator()() exchanges the order of the sums in the definition, i.e., ∑n = 0..Nm = 0..n becomes ∑m = 0..Nn = m..N.. SphericalHarmonic2::Circle performs the inner sum over degree n (which entails about N2 operations). Calling CircularEngine::operator()() on the returned object performs the outer sum over the order m (about N operations).

See SphericalHarmonic::Circle for an example of its use.

Definition at line 279 of file SphericalHarmonic2.hpp.

References FULL, and SCHMIDT.

◆ Coefficients()

const SphericalEngine::coeff & GeographicLib::SphericalHarmonic2::Coefficients ( ) const
inline
Returns
the zeroth SphericalEngine::coeff object.

Definition at line 304 of file SphericalHarmonic2.hpp.

◆ Coefficients1()

const SphericalEngine::coeff & GeographicLib::SphericalHarmonic2::Coefficients1 ( ) const
inline
Returns
the first SphericalEngine::coeff object.

Definition at line 309 of file SphericalHarmonic2.hpp.

◆ Coefficients2()

const SphericalEngine::coeff & GeographicLib::SphericalHarmonic2::Coefficients2 ( ) const
inline
Returns
the second SphericalEngine::coeff object.

Definition at line 314 of file SphericalHarmonic2.hpp.


The documentation for this class was generated from the following file: