examples/example-CircularEngine.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::CircularEngine class
2 
3 #include <iostream>
4 #include <exception>
5 #include <vector>
8 
9 using namespace std;
10 using namespace GeographicLib;
11 
12 int main() {
13  // This computes the same value as example-SphericalHarmonic.cpp using a
14  // CircularEngine (which will be faster if many values on a circle of
15  // latitude are to be found).
16  try {
17  int N = 3; // The maxium degree
18  double ca[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; // cosine coefficients
19  vector<double> C(ca, ca + (N + 1) * (N + 2) / 2);
20  double sa[] = {6, 5, 4, 3, 2, 1}; // sine coefficients
21  vector<double> S(sa, sa + N * (N + 1) / 2);
22  double a = 1;
23  SphericalHarmonic h(C, S, N, a);
24  double x = 2, y = 3, z = 1, p = Math::hypot(x, y);
25  CircularEngine circ = h.Circle(p, z, true);
26  double v, vx, vy, vz;
27  v = circ(x/p, y/p, vx, vy, vz);
28  cout << v << " " << vx << " " << vy << " " << vz << "\n";
29  }
30  catch (const exception& e) {
31  cerr << "Caught exception: " << e.what() << "\n";
32  return 1;
33  }
34 }
StridedVectorType vy(make_vector(y, *n, std::abs(*incy)))
Scalar * y
Definition: BFloat16.h:88
#define N
Definition: gksort.c:12
DiscreteKey S(1, 2)
CircularEngine Circle(real p, real z, bool gradp) const
StridedVectorType vx(make_vector(x, *n, std::abs(*incx)))
Array< int, Dynamic, 1 > v
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Header for GeographicLib::CircularEngine class.
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
Spherical harmonic sums for a circle.
Header for GeographicLib::SphericalHarmonic class.
const double h
float * p
Spherical harmonic series.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:12