.NET wrapper for GeographicLib::SphericalHarmonic. More...
#include <SphericalHarmonic.h>
Public Types | |
enum | Normalization { Normalization::FULL, Normalization::SCHMIDT } |
Public Member Functions | |
CircularEngine | Circle (double p, double z, bool gradp) |
SphericalCoefficients | Coefficients () |
double | HarmonicSum (double x, double y, double z) |
double | HarmonicSum (double x, double y, double z, [System::Runtime::InteropServices::Out] double% gradx, [System::Runtime::InteropServices::Out] double% grady, [System::Runtime::InteropServices::Out] double% gradz) |
SphericalHarmonic (array< double >^ C, array< double >^ S, int N, double a, Normalization norm) | |
SphericalHarmonic (array< double >^ C, array< double >^ S, int N, int nmx, int mmx, double a, Normalization norm) | |
~SphericalHarmonic () | |
Private Member Functions | |
!SphericalHarmonic () | |
Private Attributes | |
std::vector< double > * | m_C |
const GeographicLib::SphericalHarmonic * | m_pSphericalHarmonic |
std::vector< double > * | m_S |
.NET wrapper for GeographicLib::SphericalHarmonic.
This class allows .NET applications to access GeographicLib::SphericalHarmonic.
This class evaluates the spherical harmonic sum
V(x, y, z) = sum(n = 0..N)[ q^(n+1) * sum(m = 0..n)[ (C[n,m] * cos(m*lambda) + S[n,m] * sin(m*lambda)) * P[n,m](cos(theta)) ] ]
where
Two normalizations are supported for Pnm
Clenshaw summation is used for the sums over both n and m. This allows the computation to be carried out without the need for any temporary arrays. See GeographicLib::SphericalEngine.cpp for more information on the implementation.
References:
C# Example:
Managed C++ Example:
Visual Basic Example:
INTERFACE DIFFERENCES:
This class replaces the GeographicLib::SphericalHarmonic::operator() with HarmonicSum.
Coefficients returns a SphericalCoefficients object.
The Normalization parameter in the constructors is passed in as an enumeration rather than an unsigned.
Definition at line 75 of file SphericalHarmonic.h.
Supported normalizations for the associated Legendre polynomials.
Enumerator | |
---|---|
FULL | Fully normalized associated Legendre polynomials. These are defined by Pnmfull(z) = (−1)m sqrt(k (2n + 1) (n − m)! / (n + m)!) Pnm(z), where Pnm(z) is Ferrers function (also known as the Legendre function on the cut or the associated Legendre polynomial) http://dlmf.nist.gov/14.7.E10 and k = 1 for m = 0 and k = 2 otherwise. The mean squared value of Pnmfull(cosθ) cos(mλ) and Pnmfull(cosθ) sin(mλ) over the sphere is 1. |
SCHMIDT | Schmidt semi-normalized associated Legendre polynomials. These are defined by Pnmschmidt(z) = (−1)m sqrt(k (n − m)! / (n + m)!) Pnm(z), where Pnm(z) is Ferrers function (also known as the Legendre function on the cut or the associated Legendre polynomial) http://dlmf.nist.gov/14.7.E10 and k = 1 for m = 0 and k = 2 otherwise. The mean squared value of Pnmschmidt(cosθ) cos(mλ) and Pnmschmidt(cosθ) sin(mλ) over the sphere is 1/(2n + 1). |
Definition at line 90 of file SphericalHarmonic.h.
|
private |
Definition at line 23 of file SphericalHarmonic.cpp.
SphericalHarmonic::SphericalHarmonic | ( | array< double >^ | C, |
array< double >^ | S, | ||
int | N, | ||
double | a, | ||
Normalization | norm | ||
) |
Constructor with a full set of coefficients specified.
[in] | C | the coefficients Cnm. |
[in] | S | the coefficients Snm. |
[in] | N | the maximum degree and order of the sum |
[in] | a | the reference radius appearing in the definition of the sum. |
[in] | norm | the normalization for the associated Legendre polynomials, either SphericalHarmonic::full (the default) or SphericalHarmonic::schmidt. |
GeographicErr | if N does not satisfy N ≥ −1. |
GeographicErr | if C or S is not big enough to hold the coefficients. |
The coefficients Cnm and Snm are stored in the one-dimensional vectors C and S which must contain (N + 1)(N + 2)/2 and N (N + 1)/2 elements, respectively, stored in "column-major" order. Thus for N = 3, the order would be: C00, C10, C20, C30, C11, C21, C31, C22, C32, C33. In general the (n,m) element is at index m N − m (m − 1)/2 + n. The layout of S is the same except that the first column is omitted (since the m = 0 terms never contribute to the sum) and the 0th element is S11
The class stores pointers to the first elements of C and S. These arrays should not be altered or destroyed during the lifetime of a SphericalHarmonic object.
Definition at line 43 of file SphericalHarmonic.cpp.
SphericalHarmonic::SphericalHarmonic | ( | array< double >^ | C, |
array< double >^ | S, | ||
int | N, | ||
int | nmx, | ||
int | mmx, | ||
double | a, | ||
Normalization | norm | ||
) |
Constructor with a subset of coefficients specified.
[in] | C | the coefficients Cnm. |
[in] | S | the coefficients Snm. |
[in] | N | the degree used to determine the layout of C and S. |
[in] | nmx | the maximum degree used in the sum. The sum over n is from 0 thru nmx. |
[in] | mmx | the maximum order used in the sum. The sum over m is from 0 thru min(n, mmx). |
[in] | a | the reference radius appearing in the definition of the sum. |
[in] | norm | the normalization for the associated Legendre polynomials, either SphericalHarmonic::FULL (the default) or SphericalHarmonic::SCHMIDT. |
GeographicErr | if N, nmx, and mmx do not satisfy N ≥ nmx ≥ mmx ≥ −1. |
GeographicErr | if C or S is not big enough to hold the coefficients. |
The class stores pointers to the first elements of C and S. These arrays should not be altered or destroyed during the lifetime of a SphericalHarmonic object.
Definition at line 71 of file SphericalHarmonic.cpp.
|
inline |
The destructor calls the finalizer
Definition at line 208 of file SphericalHarmonic.h.
CircularEngine SphericalHarmonic::Circle | ( | double | p, |
double | z, | ||
bool | gradp | ||
) |
Create a CircularEngine to allow the efficient evaluation of several points on a circle of latitude.
[in] | p | the radius of the circle. |
[in] | z | the height of the circle above the equatorial plane. |
[in] | gradp | if true the returned object will be able to compute the gradient of the sum. |
std::bad_alloc | if the memory for the CircularEngine can't be allocated. |
SphericalHarmonic::operator()() exchanges the order of the sums in the definition, i.e., ∑n = 0..N ∑m = 0..n becomes ∑m = 0..N ∑n = m..N. SphericalHarmonic::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).
Definition at line 118 of file SphericalHarmonic.cpp.
SphericalCoefficients SphericalHarmonic::Coefficients | ( | ) |
Definition at line 124 of file SphericalHarmonic.cpp.
double SphericalHarmonic::HarmonicSum | ( | double | x, |
double | y, | ||
double | z | ||
) |
Compute the spherical harmonic sum.
[in] | x | cartesian coordinate. |
[in] | y | cartesian coordinate. |
[in] | z | cartesian coordinate. |
This routine requires constant memory and thus never throws an exception.
Definition at line 100 of file SphericalHarmonic.cpp.
double SphericalHarmonic::HarmonicSum | ( | double | x, |
double | y, | ||
double | z, | ||
[System::Runtime::InteropServices::Out] double% | gradx, | ||
[System::Runtime::InteropServices::Out] double% | grady, | ||
[System::Runtime::InteropServices::Out] double% | gradz | ||
) |
Compute a spherical harmonic sum and its gradient.
[in] | x | cartesian coordinate. |
[in] | y | cartesian coordinate. |
[in] | z | cartesian coordinate. |
[out] | gradx | x component of the gradient |
[out] | grady | y component of the gradient |
[out] | gradz | z component of the gradient |
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 106 of file SphericalHarmonic.cpp.
|
private |
Definition at line 85 of file SphericalHarmonic.h.
|
private |
Definition at line 79 of file SphericalHarmonic.h.
|
private |
Definition at line 85 of file SphericalHarmonic.h.