16# pragma warning (disable: 5055)
26 , _c2(_ell.Area() / (2 *
Math::td))
29#if GEOGRAPHICLIB_RHUMBAREA_ORDER == 4
30 static const real coeff[] = {
32 691, 7860, -20160, 18900, 0, 56700,
34 1772, -5340, 6930, -4725, 14175,
36 -1747, 1590, -630, 4725,
42#elif GEOGRAPHICLIB_RHUMBAREA_ORDER == 5
43 static const real coeff[] = {
45 -79036, 22803, 259380, -665280, 623700, 0, 1871100,
47 41662, 58476, -176220, 228690, -155925, 467775,
49 18118, -57651, 52470, -20790, 155925,
51 -23011, 17160, -5115, 51975,
57#elif GEOGRAPHICLIB_RHUMBAREA_ORDER == 6
58 static const real coeff[] = {
60 128346268, -107884140, 31126095, 354053700, -908107200, 851350500, 0,
63 -114456994, 56868630, 79819740, -240540300, 312161850, -212837625,
66 51304574, 24731070, -78693615, 71621550, -28378350, 212837625,
68 1554472, -6282003, 4684680, -1396395, 14189175,
70 -4913956, 3205800, -791505, 8108100,
72 1092376, -234468, 2027025,
76#elif GEOGRAPHICLIB_RHUMBAREA_ORDER == 7
77 static const real coeff[] = {
79 -317195588, 385038804, -323652420, 93378285, 1062161100, -2724321600LL,
80 2554051500LL, 0, 7662154500LL,
82 258618446, -343370982, 170605890, 239459220, -721620900, 936485550,
83 -638512875, 1915538625,
85 -248174686, 153913722, 74193210, -236080845, 214864650, -85135050,
88 114450437, 23317080, -94230045, 70270200, -20945925, 212837625,
90 15445736, -103193076, 67321800, -16621605, 170270100,
92 -27766753, 16385640, -3517020, 30405375,
94 4892722, -939228, 6081075,
98#elif GEOGRAPHICLIB_RHUMBAREA_ORDER == 8
99 static const real coeff[] = {
101 71374704821LL, -161769749880LL, 196369790040LL, -165062734200LL,
102 47622925350LL, 541702161000LL, -1389404016000LL, 1302566265000LL, 0,
105 -13691187484LL, 65947703730LL, -87559600410LL, 43504501950LL,
106 61062101100LL, -184013329500LL, 238803815250LL, -162820783125LL,
109 30802104839LL, -63284544930LL, 39247999110LL, 18919268550LL,
110 -60200615475LL, 54790485750LL, -21709437750LL, 162820783125LL,
112 -8934064508LL, 5836972287LL, 1189171080, -4805732295LL, 3583780200LL,
113 -1068242175, 10854718875LL,
115 50072287748LL, 3938662680LL, -26314234380LL, 17167059000LL,
116 -4238509275LL, 43418875500LL,
118 359094172, -9912730821LL, 5849673480LL, -1255576140, 10854718875LL,
120 -16053944387LL, 8733508770LL, -1676521980, 10854718875LL,
122 930092876, -162639357, 723647925,
124 -673429061, 1929727800,
127#error "Bad value for GEOGRAPHICLIB_RHUMBAREA_ORDER"
129 static_assert(
sizeof(coeff) /
sizeof(real) ==
130 ((maxpow_ + 1) * (maxpow_ + 4))/2,
131 "Coefficient array size mismatch for Rhumb");
134 for (
int l = 0; l <= maxpow_; ++l) {
140 _rR[l] = d *
Math::polyval(m, coeff + o, _ell._n) / coeff[o + m + 1];
153 void Rhumb::GenInverse(real lat1, real lon1, real lat2, real lon2,
155 real& s12, real& azi12, real& S12)
const {
161 h = hypot(lon12, psi12);
165 real dmudpsi = DIsometricToRectifying(psi2, psi1);
174 {
return RhumbLine(*
this, lat1, lon1, azi12); }
176 void Rhumb::GenDirect(real lat1, real lon1, real azi12, real s12,
178 real& lat2, real& lon2, real& S12)
const
179 {
Line(lat1, lon1, azi12).
GenPosition(s12, outmask, lat2, lon2, S12); }
185 return d != 0 ? (ei.
E(x) - ei.
E(y)) / d : 1;
201 real sx = sin(x), sy = sin(y), cx = cos(x), cy = cos(y);
202 real Dt = Dsin(x, y) * (sx + sy) /
203 ((cx + cy) * (sx * ei.
Delta(sy, cy) + sy * ei.
Delta(sx, cx))),
204 t = d * Dt, Dsz = 2 * Dt / (1 + t*t),
205 sz = d * Dsz, cz = (1 - t) * (1 + t) / (1 + t*t);
206 return ((sz != 0 ? ei.
E(sz, cz, ei.
Delta(sz, cz)) / sz : 1)
207 - ei.
k2() * sx * sy) * Dsz;
214 return (
Math::pi()/2) * _ell._b * _ell._f1 * DE(atan(tbetx), atan(tbety))
222 return Dasinh(tx, ty) * Dtan(latx, laty)
223 - Deatanhe(sin(phix), sin(phiy)) * Dsin(phix, phiy);
261 real p = x + y, d = x - y,
262 cp = cos(p), cd = cos(d),
263 sp = sin(p), sd = d != 0 ? sin(d)/d : 1,
264 m = 2 * cp * cd, s = sp * sd;
266 const real a[4] = {m, -s * d * d, -4 * s, m};
267 real ba[4] = {0, 0, 0, 0};
268 real bb[4] = {0, 0, 0, 0};
271 if (n > 0) b1[0] = b1[3] = c[n];
272 for (
int j = n - 1; j > 0; --j) {
275 b1[0] = a[0] * b2[0] + a[1] * b2[2] - b1[0] + c[j];
276 b1[1] = a[0] * b2[1] + a[1] * b2[3] - b1[1];
277 b1[2] = a[2] * b2[0] + a[3] * b2[2] - b1[2];
278 b1[3] = a[2] * b2[1] + a[3] * b2[3] - b1[3] + c[j];
285 real f11 = cd * sp, f12 = 2 * sd * cp;
287 s = b1[2] * f11 + b1[3] * f12;
290 real f11 = cd * cp, f12 = - 2 * sd * sp;
292 s = - b2[2] + b1[2] * f11 + b1[3] * f12;
298 return 1 + SinCosSeries(
true, chix, chiy,
299 _ell.ConformalToRectifyingCoeffs(), tm_maxord);
303 return 1 - SinCosSeries(
true, mux, muy,
304 _ell.RectifyingToConformalCoeffs(), tm_maxord);
312 return DRectifying(latx, laty) / DIsometric(latx, laty);
316 return DConformalToRectifying(gd(psix), gd(psiy)) * Dgd(psix, psiy);
325 DIsometric(latx, laty) / DRectifying(latx, laty) :
326 Dgdinv(Math::taupf(Math::tand(latx), _ell._es),
327 Math::taupf(Math::tand(laty), _ell._es)) *
328 DRectifyingToConformal(mux, muy);
332 return Dlog(cosh(psix), cosh(psiy)) * Dcosh(psix, psiy)
333 + SinCosSeries(
false, gd(psix), gd(psiy), _rR, maxpow_) * Dgd(psix, psiy);
336 RhumbLine::RhumbLine(
const Rhumb& rh,
real lat1,
real lon1,
real azi12)
338 , _lat1(Math::LatFix(lat1))
340 , _azi12(Math::AngNormalize(azi12))
343 _salp = _azi12 == -
Math::hd ? 0 : sin(alp12);
344 _calp = fabs(_azi12) ==
Math::qd ? 0 : cos(alp12);
345 _mu1 = _rh._ell.RectifyingLatitude(lat1);
346 _psi1 = _rh._ell.IsometricLatitude(lat1);
347 _r1 = _rh._ell.CircleRadius(lat1);
351 real& lat2, real& lon2, real& S12)
const {
355 real psi2, lat2x, lon2x;
359 real psi12 = _rh.DRectifyingToIsometric( mu2 *
Math::degree(),
361 lon2x = _salp * psi12 / _calp;
362 psi2 = _psi1 + psi12;
369 S12 = _rh._c2 * lon2x *
383 if (outmask &
LATITUDE) lat2 = lat2x;
GeographicLib::Math::real real
Header for GeographicLib::Rhumb and GeographicLib::RhumbLine classes.
Math::real IsometricLatitude(real phi) const
Math::real QuarterMeridian() const
Math::real InverseIsometricLatitude(real psi) const
Math::real InverseRectifyingLatitude(real mu) const
Elliptic integrals and functions.
Math::real Delta(real sn, real cn) const
Mathematical functions needed by GeographicLib.
static T atan2d(T y, T x)
static T AngNormalize(T x)
static T polyval(int N, const T p[], T x)
static T AngDiff(T x, T y, T &e)
@ hd
degrees per half turn
@ qd
degrees per quarter turn
Find a sequence of points on a single rhumb line.
void GenPosition(real s12, unsigned outmask, real &lat2, real &lon2, real &S12) const
Solve of the direct and inverse rhumb problems.
RhumbLine Line(real lat1, real lon1, real azi12) const
Rhumb(real a, real f, bool exact=true)
static const Rhumb & WGS84()
Namespace for GeographicLib.
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)