GeographicLib: PolarStereographic.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
11
13
14 using namespace std;
15
17 : _a(a)
18 , _f(f)
19 , _e2(_f * (2 - _f))
20 , _es((_f < 0 ? -1 : 1) * sqrt(fabs(_e2)))
21 , _e2m(1 - _e2)
22 , _c( (1 - _f) * exp(Math::eatanhe(real(1), _es)) )
23 , _k0(k0)
24 {
25 if (!(isfinite(_a) && _a > 0))
26 throw GeographicErr("Equatorial radius is not positive");
27 if (!(isfinite(_f) && _f < 1))
28 throw GeographicErr("Polar semi-axis is not positive");
29 if (!(isfinite(_k0) && _k0 > 0))
31 }
32
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
62 real& x, real& y,
63 real& gamma, real& k) const {
65 lat *= northp ? 1 : -1;
66 real
68 secphi = hypot(real(1), tau),
70 rho = hypot(real(1), taup) + fabs(taup);
71 rho = taup >= 0 ? (lat != Math::qd ? 1/rho : 0) : rho;
72 rho *= 2 * _k0 * _a / _c;
74 (rho / _a) * secphi * sqrt(_e2m + _e2 / Math::sq(secphi)) : _k0;
76 x *= rho;
77 y *= (northp ? -rho : rho);
79 }
80
82 real& lat, real& lon,
83 real& gamma, real& k) const {
84 real
85 rho = hypot(x, y),
86 t = rho != 0 ? rho / (2 * _k0 * _a / _c) :
87 Math::sq(numeric_limits::epsilon()),
88 taup = (1 / t - t) / 2,
90 secphi = hypot(real(1), tau);
91 k = rho != 0 ? (rho / _a) * secphi * sqrt(_e2m + _e2 / Math::sq(secphi)) :
92 _k0;
93 lat = (northp ? 1 : -1) * Math::atand(tau);
96 }
97
99 if (!(isfinite(k) && k > 0))
103 + "d, " + to_string(Math::qd) + "d]");
104 real x, y, gamma, kold;
105 _k0 = 1;
106 Forward(true, lat, 0, x, y, gamma, kold);
107 _k0 *= k/kold;
108 }
109
110}
Header for GeographicLib::PolarStereographic class.
Exception handling for GeographicLib.
Mathematical functions needed by GeographicLib.
static void sincosd(T x, T &sinx, T &cosx)
static T atan2d(T y, T x)
static constexpr int qd
degrees per quarter turn
static T tauf(T taup, T es)
static T AngNormalize(T x)
static T taupf(T tau, T es)
Polar stereographic projection.
void Reverse(bool northp, real x, real y, real &lat, real &lon, real &gamma, real &k) const
Definition PolarStereographic.cpp:81
PolarStereographic(real a, real f, real k0)
Definition PolarStereographic.cpp:16
void SetScale(real lat, real k=real(1))
Definition PolarStereographic.cpp:98
static const PolarStereographic & UPS()
Definition PolarStereographic.cpp:33
void Forward(bool northp, real lat, real lon, real &x, real &y, real &gamma, real &k) const
Definition PolarStereographic.cpp:61
Namespace for GeographicLib.