Geocentric.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_GEOCENTRIC_HPP)
11 #define GEOGRAPHICLIB_GEOCENTRIC_HPP 1
12 
13 #include <vector>
15 
16 namespace GeographicLib {
17 
68  private:
69  typedef Math::real real;
70  friend class LocalCartesian;
71  friend class MagneticCircle; // MagneticCircle uses Rotation
72  friend class MagneticModel; // MagneticModel uses IntForward
73  friend class GravityCircle; // GravityCircle uses Rotation
74  friend class GravityModel; // GravityModel uses IntForward
75  friend class NormalGravity; // NormalGravity uses IntForward
76  static const size_t dim_ = 3;
77  static const size_t dim2_ = dim_ * dim_;
78  real _a, _f, _e2, _e2m, _e2a, _e4a, _maxrad;
79  static void Rotation(real sphi, real cphi, real slam, real clam,
80  real M[dim2_]);
81  static void Rotate(real M[dim2_], real x, real y, real z,
82  real& X, real& Y, real& Z) {
83  // Perform [X,Y,Z]^t = M.[x,y,z]^t
84  // (typically local cartesian to geocentric)
85  X = M[0] * x + M[1] * y + M[2] * z;
86  Y = M[3] * x + M[4] * y + M[5] * z;
87  Z = M[6] * x + M[7] * y + M[8] * z;
88  }
89  static void Unrotate(real M[dim2_], real X, real Y, real Z,
90  real& x, real& y, real& z) {
91  // Perform [x,y,z]^t = M^t.[X,Y,Z]^t
92  // (typically geocentric to local cartesian)
93  x = M[0] * X + M[3] * Y + M[6] * Z;
94  y = M[1] * X + M[4] * Y + M[7] * Z;
95  z = M[2] * X + M[5] * Y + M[8] * Z;
96  }
97  void IntForward(real lat, real lon, real h, real& X, real& Y, real& Z,
98  real M[dim2_]) const;
99  void IntReverse(real X, real Y, real Z, real& lat, real& lon, real& h,
100  real M[dim2_]) const;
101 
102  public:
103 
113  Geocentric(real a, real f);
114 
118  Geocentric() : _a(-1) {}
119 
132  void Forward(real lat, real lon, real h, real& X, real& Y, real& Z)
133  const {
134  if (Init())
135  IntForward(lat, lon, h, X, Y, Z, NULL);
136  }
137 
161  void Forward(real lat, real lon, real h, real& X, real& Y, real& Z,
162  std::vector<real>& M)
163  const {
164  if (!Init())
165  return;
166  if (M.end() == M.begin() + dim2_) {
167  real t[dim2_];
168  IntForward(lat, lon, h, X, Y, Z, t);
169  std::copy(t, t + dim2_, M.begin());
170  } else
171  IntForward(lat, lon, h, X, Y, Z, NULL);
172  }
173 
194  void Reverse(real X, real Y, real Z, real& lat, real& lon, real& h)
195  const {
196  if (Init())
197  IntReverse(X, Y, Z, lat, lon, h, NULL);
198  }
199 
223  void Reverse(real X, real Y, real Z, real& lat, real& lon, real& h,
224  std::vector<real>& M)
225  const {
226  if (!Init())
227  return;
228  if (M.end() == M.begin() + dim2_) {
229  real t[dim2_];
230  IntReverse(X, Y, Z, lat, lon, h, t);
231  std::copy(t, t + dim2_, M.begin());
232  } else
233  IntReverse(X, Y, Z, lat, lon, h, NULL);
234  }
235 
238 
242  bool Init() const { return _a > 0; }
248  { return Init() ? _a : Math::NaN(); }
249 
255  { return Init() ? _f : Math::NaN(); }
257 
262  static const Geocentric& WGS84();
263  };
264 
265 } // namespace GeographicLib
266 
267 #endif // GEOGRAPHICLIB_GEOCENTRIC_HPP
static void Rotate(real M[dim2_], real x, real y, real z, real &X, real &Y, real &Z)
Definition: Geocentric.hpp:81
static T NaN()
Definition: Math.hpp:830
void Forward(real lat, real lon, real h, real &X, real &Y, real &Z, std::vector< real > &M) const
Definition: Geocentric.hpp:161
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:38
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
Scalar * y
static const double lat
The normal gravity of the earth.
void Forward(real lat, real lon, real h, real &X, real &Y, real &Z) const
Definition: Geocentric.hpp:132
Model of the earth&#39;s magnetic field.
Geomagnetic field on a circle of latitude.
Array33i a
Geocentric coordinates
Definition: Geocentric.hpp:67
#define Z
Definition: icosphere.cpp:21
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Namespace for GeographicLib.
Math::real Flattening() const
Definition: Geocentric.hpp:254
#define NULL
Definition: ccolamd.c:609
Math::real MajorRadius() const
Definition: Geocentric.hpp:247
Local cartesian coordinates.
Model of the earth&#39;s gravity field.
const double h
void Reverse(real X, real Y, real Z, real &lat, real &lon, real &h) const
Definition: Geocentric.hpp:194
void Reverse(real X, real Y, real Z, real &lat, real &lon, real &h, std::vector< real > &M) const
Definition: Geocentric.hpp:223
static void Unrotate(real M[dim2_], real X, real Y, real Z, real &x, real &y, real &z)
Definition: Geocentric.hpp:89
Header for GeographicLib::Constants class.
static const double lon
#define X
Definition: icosphere.cpp:20
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
Point2 t(10, 10)
Gravity on a circle of latitude.


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:07