File: example-SphericalHarmonic2.cpp

package info (click to toggle)
geographiclib 1.37-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,688 kB
  • ctags: 4,871
  • sloc: cpp: 31,440; sh: 11,632; cs: 9,411; ansic: 1,428; java: 1,333; python: 1,131; makefile: 758; xml: 381; pascal: 30
file content (38 lines) | stat: -rw-r--r-- 1,257 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Example of using the GeographicLib::SphericalHarmonic2 class

#include <iostream>
#include <exception>
#include <vector>
#include <GeographicLib/SphericalHarmonic2.hpp>

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;
  }
  return 0;
}