1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Precompute e2s as well

This commit is contained in:
Martin Tůma 2018-05-18 22:10:43 +02:00
parent d9c922aa47
commit a6389f0174
3 changed files with 4 additions and 3 deletions

View File

@ -70,6 +70,7 @@ Ellipsoid::Ellipsoid(double radius, double flattening)
: _radius(radius), _flattening(flattening)
{
_es = 2.0 * flattening - flattening * flattening;
_e2s = (1.0 / (1.0 - _es)) - 1.0;
_b = radius * (1.0 - flattening);
}

View File

@ -15,6 +15,7 @@ public:
double radius() const {return _radius;}
double flattening() const {return _flattening;}
double es() const {return _es;}
double e2s() const {return _e2s;}
double b() const {return _b;}
bool isNull() const
@ -28,7 +29,7 @@ public:
private:
double _radius;
double _flattening;
double _es, _b;
double _es, _e2s, _b;
static QMap<int, Ellipsoid> WGS84();
static QMap<int, Ellipsoid> _ellipsoids;

View File

@ -65,7 +65,6 @@ Point3D Geocentric::fromGeodetic(const Coordinates &c, const Ellipsoid *e)
Coordinates Geocentric::toGeodetic(const Point3D &p, const Ellipsoid *e)
{
double ep2 = (1.0 / (1.0 - e->es())) - 1.0;
bool pole = false;
double lat, lon;
@ -94,7 +93,7 @@ Coordinates Geocentric::toGeodetic(const Point3D &p, const Ellipsoid *e)
double Sin_B0 = T0 / S0;
double Cos_B0 = W / S0;
double Sin3_B0 = Sin_B0 * Sin_B0 * Sin_B0;
double T1 = p.z() + e->b() * ep2 * Sin3_B0;
double T1 = p.z() + e->b() * e->e2s() * Sin3_B0;
double Sum = W - e->radius() * e->es() * Cos_B0 * Cos_B0 * Cos_B0;
double S1 = sqrt(T1*T1 + Sum * Sum);
double Sin_p1 = T1 / S1;