00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GCL_ELLIPSOID_INCLUDED
00022 #define GCL_ELLIPSOID_INCLUDED
00023
00024 #include <string>
00025 #include <iostream>
00026 #include <cmath>
00027 #include "mpc.h"
00028
00029 using namespace std;
00030 using namespace GenLib2;
00031
00033 namespace GCL
00034 {
00035
00081 class Ellipsoid
00082 {
00083 public:
00091 Ellipsoid();
00092
00099 Ellipsoid(const char* name, double a, double f)
00100 {
00101 set(name, a, f);
00102 }
00103
00111 Ellipsoid(const string& name);
00112
00114 virtual ~Ellipsoid() {}
00116
00129 void set(const char* name, double a, double f);
00130
00137 bool set(istream& is, const string& name);
00138
00145 bool set(const string& fname, const string& name);
00146
00152 bool set(const string& name);
00154
00158 void print(ostream& os) const;
00159
00161 const char* ell_name() const { return _name.c_str(); }
00162
00164 bool is_valid() const { return (_a > 0.) ? true : false; }
00165
00171 double nradius(double b) const;
00172
00178 double mradius(double b) const;
00179
00184 double dist(double psi) const;
00185
00190 double arc(double b) const;
00191
00196 double inv_arc(double g) const;
00197
00203 double q(double b) const;
00204
00210 double inv_q(double q) const;
00211
00220 double geog_to_geoc(double b) const;
00221
00226 double geoc_to_geog(double psi) const;
00228
00240 void geo_to_cart(double b, double l, double h,
00241 double& x, double& y, double& z) const;
00242
00249 void cart_to_geo(double x, double y, double z,
00250 double& b, double& l, double& h) const;
00252
00253 protected:
00255 string _name;
00256
00258 double _a;
00259
00261 double _b;
00262
00264 double _c;
00265
00267 double _f;
00268
00270 double _e2;
00271
00273 double _e22;
00274
00275 private:
00277
00278
00279 double _a0;
00280
00282 double _a1;
00283
00285 double _a2;
00286
00288 double _a4;
00289
00291 double _a6;
00292
00294 double _a8;
00296
00302 void calc_params();
00303
00305 void calc_coeffs();
00306
00308 void funcd(double x, double h, double& fn, double& df) const;
00309 };
00310
00311
00312
00313
00314
00315
00316 inline double Ellipsoid::nradius(double phi) const
00317 {
00318 double sin_phi = sin(phi);
00319 return (_a / sqrt(1. - _e2 * sin_phi * sin_phi));
00320 }
00321
00322
00323
00324
00325 inline double Ellipsoid::mradius(double phi) const
00326 {
00327 double sin_phi = sin(phi);
00328 return (_a * (1. - _e2) / pow(1. - _e2 * sin_phi * sin_phi, 1.5));
00329 }
00330
00331
00332
00333
00334 inline double Ellipsoid::dist(double psi) const
00335 {
00336 double cos_psi = cos(psi);
00337 double b2 = _a * _a * (1. - _e2);
00338 return sqrt(b2 / (1. - _e2 * cos_psi * cos_psi));
00339
00340 }
00341
00342 }
00343
00344 #endif