File: example-EllipticFunction.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 (42 lines) | stat: -rw-r--r-- 1,762 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
39
40
41
42
// Example of using the GeographicLib::EllipticFunction class

#include <iostream>
#include <iomanip>
#include <cmath>
#include <GeographicLib/Math.hpp>
#include <GeographicLib/EllipticFunction.hpp>

using namespace std;
using namespace GeographicLib;

int main() {
  try {
    EllipticFunction ell(0.1);  // parameter m = 0.1
    // See Abramowitz and Stegun, table 17.1
    cout << ell.K() << " " << ell.E() << "\n";
    double phi = 20 * Math::degree();
    // See Abramowitz and Stegun, table 17.6 with
    // alpha = asin(sqrt(m)) = 18.43 deg and phi = 20 deg
    cout << ell.E(phi) << " "
         << ell.E(sin(phi), cos(phi), sqrt(1 - ell.k2() * Math::sq(sin(phi))))
         << "\n";
    // See Carlson 1995, Sec 3.
    cout << fixed << setprecision(16)
         << "RF(1,2,0)      = " << EllipticFunction::RF(1,2)      << "\n"
         << "RF(2,3,4)      = " << EllipticFunction::RF(2,3,4)    << "\n"
         << "RC(0,1/4)      = " << EllipticFunction::RC(0,0.25)   << "\n"
         << "RC(9/4,2)      = " << EllipticFunction::RC(2.25,2)   << "\n"
         << "RC(1/4,-2)     = " << EllipticFunction::RC(0.25,-2)  << "\n"
         << "RJ(0,1,2,3)    = " << EllipticFunction::RJ(0,1,2,3)  << "\n"
         << "RJ(2,3,4,5)    = " << EllipticFunction::RJ(2,3,4,5)  << "\n"
         << "RD(0,2,1)      = " << EllipticFunction::RD(0,2,1)    << "\n"
         << "RD(2,3,4)      = " << EllipticFunction::RD(2,3,4)    << "\n"
         << "RG(0,16,16)    = " << EllipticFunction::RG(16,16)    << "\n"
         << "RG(2,3,4)      = " << EllipticFunction::RG(2,3,4)    << "\n"
         << "RG(0,0.0796,4) = " << EllipticFunction::RG(0.0796,4) << "\n";
  }
  catch (const GeographicErr& e) {
    cout << "Caught exception: " << e.what() << "\n";
  }
  return 0;
}