File: example-Ellipsoid3.cpp

package info (click to toggle)
geographiclib 2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,572 kB
  • sloc: cpp: 27,765; sh: 5,463; makefile: 695; python: 12; ansic: 10
file content (34 lines) | stat: -rw-r--r-- 1,023 bytes parent folder | download
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
// Example of using the Triaxial::Ellipsoid3 class.

#include <iostream>
#include <iomanip>
#include <exception>
#include <GeographicLib/Triaxial/Ellipsoid3.hpp>

using namespace std;
using namespace GeographicLib;

int main() {
  try {
    using Triaxial::Ellipsoid3;
    using ang = Angle;
    using vec3 = Ellipsoid3::vec3;
    Ellipsoid3 t(3, 2, 1);
    ang bet{40}, omg{20}, alp{80};
    vec3 r, v;
    t.elliptocart2(bet, omg, alp, r, v);
    cout  << fixed << setprecision(3)
          << "[bet, omg, alp] = ["
          << double(bet) << " " << double(omg) << " " << double(alp)
          << "]\n => r = [" << r[0] << " " << r[1] << " " << r[2]
          << "], v = [" << v[0] << " " << v[1] << " " << v[2] << "]\n";
    ang betn, omgn, alpn;
    t.cart2toellip(r, v, betn, omgn, alpn);
    cout << " => [bet, omg, alp] = ["
         << double(betn) << " " << double(omgn) << " " << double(alpn) << "]\n";
  }
  catch (const exception& e) {
    cerr << "Caught exception: " << e.what() << "\n";
    return 1;
  }
}