make-egmcof.cpp
Go to the documentation of this file.
1 // Write the coefficient files needed for approximating the normal gravity
2 // field with a GravityModel. WARNING: this creates files, wgs84.egm.cof and
3 // grs80.egm.cof, in the current directory.
4 
5 #include <cmath>
6 #include <fstream>
7 #include <iostream>
10 
11 using namespace std;
12 using namespace GeographicLib;
13 
14 int main() {
15  try {
16  Utility::set_digits();
17  const char* filenames[] = {"wgs84.egm.cof", "grs80.egm.cof"};
18  const char* ids[] = {"WGS1984A", "GRS1980A"};
19  for (int grs80 = 0; grs80 < 2; ++grs80) {
20  ofstream file(filenames[grs80], ios::binary);
21  Utility::writearray<char, char, false>(file, ids[grs80], 8);
22  const int N = 20, M = 0,
23  cnum = (M + 1) * (2 * N - M + 2) / 2; // cnum = N + 1
24  vector<int> num(2);
25  num[0] = N; num[1] = M;
26  Utility::writearray<int, int, false>(file, num);
27  vector<Math::real> c(cnum, 0);
28  const NormalGravity& earth(grs80 ? NormalGravity::GRS80() :
29  NormalGravity::WGS84());
30  for (int n = 2; n <= N; n += 2)
31  c[n] = - earth.DynamicalFormFactor(n) / sqrt(Math::real(2*n + 1));
32  Utility::writearray<double, Math::real, false>(file, c);
33  num[0] = num[1] = -1;
34  Utility::writearray<int, int, false>(file, num);
35  }
36  }
37  catch (const exception& e) {
38  cerr << "Caught exception: " << e.what() << "\n";
39  return 1;
40  }
41  catch (...) {
42  cerr << "Caught unknown exception\n";
43  return 1;
44  }
45 }
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
n
int n
Definition: BiCGSTAB_simple.cpp:1
GeographicLib::Math::real
double real
Definition: Math.hpp:129
GeographicLib::NormalGravity
The normal gravity of the earth.
Definition: NormalGravity.hpp:79
Utility.hpp
Header for GeographicLib::Utility class.
gtsam
traits
Definition: SFMdata.h:40
std
Definition: BFloat16.h:88
GeographicLib::NormalGravity::DynamicalFormFactor
Math::real DynamicalFormFactor(int n=2) const
Definition: NormalGravity.hpp:322
N
#define N
Definition: igam.h:9
NormalGravity.hpp
Header for GeographicLib::NormalGravity class.
main
int main()
Definition: make-egmcof.cpp:14
matlab_wrap.file
file
Definition: matlab_wrap.py:57
ceres::sqrt
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:57