49 , _es((_f < 0 ? -1 : 1) * sqrt(abs(_e2)))
53 , _c( sqrt(_e2m) * exp(
Math::eatanhe(real(1), _es)) )
56 if (!(isfinite(_a) && _a > 0))
58 if (!(isfinite(_f) && _f < 1))
60 if (!(isfinite(_k0) && _k0 > 0))
64#if GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER/2 == 2
65 static const real b1coeff[] = {
69#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER/2 == 3
70 static const real b1coeff[] = {
74#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER/2 == 4
75 static const real b1coeff[] = {
77 25, 64, 256, 4096, 16384, 16384,
80#error "Bad value for GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER"
83#if GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 4
84 static const real alpcoeff[] = {
86 164, 225, -480, 360, 720,
94#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 5
95 static const real alpcoeff[] = {
97 -635, 328, 450, -960, 720, 1440,
99 4496, 3899, -6048, 2730, 10080,
101 15061, -19776, 6832, 26880,
103 -171840, 49561, 161280,
107#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 6
108 static const real alpcoeff[] = {
110 31564, -66675, 34440, 47250, -100800, 75600, 151200,
112 -1983433, 863232, 748608, -1161216, 524160, 1935360,
114 670412, 406647, -533952, 184464, 725760,
116 6601661, -7732800, 2230245, 7257600,
118 -13675556, 3438171, 7983360,
120 212378941, 319334400,
122#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 7
123 static const real alpcoeff[] = {
125 1804025, 2020096, -4267200, 2204160, 3024000, -6451200, 4838400, 9676800,
127 4626384, -9917165, 4316160, 3743040, -5806080, 2620800, 9676800,
129 -67102379, 26816480, 16265880, -21358080, 7378560, 29030400,
131 155912000, 72618271, -85060800, 24532695, 79833600,
133 102508609, -109404448, 27505368, 63866880,
135 -12282192400LL, 2760926233LL, 4151347200LL,
137 1522256789, 1383782400,
139#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 8
140 static const real alpcoeff[] = {
142 -75900428, 37884525, 42422016, -89611200, 46287360, 63504000, -135475200,
143 101606400, 203212800,
145 148003883, 83274912, -178508970, 77690880, 67374720, -104509440,
148 318729724, -738126169, 294981280, 178924680, -234938880, 81164160,
151 -40176129013LL, 14967552000LL, 6971354016LL, -8165836800LL, 2355138720LL,
154 10421654396LL, 3997835751LL, -4266773472LL, 1072709352, 2490808320LL,
156 175214326799LL, -171950693600LL, 38652967262LL, 58118860800LL,
158 -67039739596LL, 13700311101LL, 12454041600LL,
160 1424729850961LL, 743921418240LL,
163#error "Bad value for GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER"
166#if GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 4
167 static const real betcoeff[] = {
169 -4, 555, -960, 720, 1440,
177#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 5
178 static const real betcoeff[] = {
180 -3645, -64, 8880, -15360, 11520, 23040,
182 4416, -3059, 672, 210, 10080,
184 -627, -592, 476, 13440,
190#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 6
191 static const real betcoeff[] = {
193 384796, -382725, -6720, 932400, -1612800, 1209600, 2419200,
195 -1118711, 1695744, -1174656, 258048, 80640, 3870720,
197 22276, -16929, -15984, 12852, 362880,
199 -830251, -158400, 197865, 7257600,
201 -435388, 453717, 15966720,
205#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 7
206 static const real betcoeff[] = {
208 -5406467, 6156736, -6123600, -107520, 14918400, -25804800, 19353600,
211 829456, -5593555, 8478720, -5873280, 1290240, 403200, 19353600,
213 9261899, 3564160, -2708640, -2557440, 2056320, 58060800,
215 14928352, -9132761, -1742400, 2176515, 79833600,
217 -8005831, -1741552, 1814868, 63866880,
219 -261810608, 268433009, 8302694400LL,
221 219941297, 5535129600LL,
223#elif GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER == 8
224 static const real betcoeff[] = {
226 31777436, -37845269, 43097152, -42865200, -752640, 104428800, -180633600,
227 135475200, 270950400,
229 24749483, 14930208, -100683990, 152616960, -105719040, 23224320, 7257600,
232 -232468668, 101880889, 39205760, -29795040, -28131840, 22619520,
235 324154477, 1433121792, -876745056, -167270400, 208945440, 7664025600LL,
237 457888660, -312227409, -67920528, 70779852, 2490808320LL,
239 -19841813847LL, -3665348512LL, 3758062126LL, 116237721600LL,
241 -1989295244, 1979471673, 49816166400LL,
243 191773887257LL, 3719607091200LL,
246#error "Bad value for GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER"
249 static_assert(
sizeof(b1coeff) /
sizeof(real) == maxpow_/2 + 2,
250 "Coefficient array size mismatch for b1");
251 static_assert(
sizeof(alpcoeff) /
sizeof(real) ==
252 (maxpow_ * (maxpow_ + 3))/2,
253 "Coefficient array size mismatch for alp");
254 static_assert(
sizeof(betcoeff) /
sizeof(real) ==
255 (maxpow_ * (maxpow_ + 3))/2,
256 "Coefficient array size mismatch for bet");
264 for (
int l = 1; l <= maxpow_; ++l) {
266 _alp[l] = d *
Math::polyval(m, alpcoeff + o, _n) / alpcoeff[o + m + 1];
267 _bet[l] = d *
Math::polyval(m, betcoeff + o, _n) / betcoeff[o + m + 1];
350 real& gamma, real& k)
const {
355 latsign = (lat < 0) ? -1 : 1,
356 lonsign = (lon < 0) ? -1 : 1;
359 bool backside = lon > 90;
365 real sphi, cphi, slam, clam;
390 xip = atan2(taup, clam);
393 etap = asinh(slam / hypot(taup, clam));
398 gamma =
Math::atan2d(slam * taup, clam * hypot(real(1), taup));
406 k = sqrt(_e2m + _e2 *
Math::sq(cphi)) * hypot(real(1), tau)
480 c0 = cos(2 * xip), ch0 = cosh(2 * etap),
481 s0 = sin(2 * xip), sh0 = sinh(2 * etap);
482 complex<real> a(2 * c0 * ch0, -2 * s0 * sh0);
485 y0(n & 1 ? _alp[n] : 0), y1,
486 z0(n & 1 ? 2*n * _alp[n] : 0), z1;
489 y1 = a * y0 - y1 + _alp[n];
490 z1 = a * z0 - z1 + 2*n * _alp[n];
492 y0 = a * y1 - y0 + _alp[n];
493 z0 = a * z1 - z0 + 2*n * _alp[n];
497 z1 = real(1) - z1 + a * z0;
498 a = complex<real>(s0 * ch0, c0 * sh0);
499 y1 = complex<real>(xip, etap) + a * y0;
504 real xi = y1.real(), eta = y1.imag();
505 y = _a1 * _k0 * (backside ?
Math::pi() - xi : xi) * latsign;
506 x = _a1 * _k0 * eta * lonsign;
509 gamma *= latsign * lonsign;
515 real& lat, real& lon,
516 real& gamma, real& k)
const {
521 xi = y / (_a1 * _k0),
522 eta = x / (_a1 * _k0);
525 xisign = (xi < 0) ? -1 : 1,
526 etasign = (eta < 0) ? -1 : 1;
533 c0 = cos(2 * xi), ch0 = cosh(2 * eta),
534 s0 = sin(2 * xi), sh0 = sinh(2 * eta);
535 complex<real> a(2 * c0 * ch0, -2 * s0 * sh0);
538 y0(n & 1 ? -_bet[n] : 0), y1,
539 z0(n & 1 ? -2*n * _bet[n] : 0), z1;
542 y1 = a * y0 - y1 - _bet[n];
543 z1 = a * z0 - z1 - 2*n * _bet[n];
545 y0 = a * y1 - y0 - _bet[n];
546 z0 = a * z1 - z0 - 2*n * _bet[n];
550 z1 = real(1) - z1 + a * z0;
551 a = complex<real>(s0 * ch0, c0 * sh0);
552 y1 = complex<real>(xi, eta) + a * y0;
562 xip = y1.real(), etap = y1.imag(),
564 c = max(real(0), cos(xip)),
575 k *= sqrt(_e2m + _e2 / (1 +
Math::sq(tau))) *
576 hypot(real(1), tau) * r;
589 gamma *= xisign * etasign;
Header for GeographicLib::TransverseMercator class.
Exception handling for GeographicLib.
Mathematical functions needed by GeographicLib.
static T AngNormalize(T x)
static void sincosd(T x, T &sinx, T &cosx)
static T atan2d(T y, T x)
static T tauf(T taup, T es)
static T taupf(T tau, T es)
static T polyval(int N, const T p[], T x)
static T AngDiff(T x, T y, T &e)
Transverse Mercator projection.
void Reverse(real lon0, real x, real y, real &lat, real &lon, real &gamma, real &k) const
static const TransverseMercator & UTM()
TransverseMercator(real a, real f, real k0)
void Forward(real lon0, real lat, real lon, real &x, real &y, real &gamma, real &k) const
Namespace for GeographicLib.