GeographicLib 2.3

Geodesic.cpp
Go to the documentation of this file.
1/**
2 * \file Geodesic.cpp
3 * \brief Implementation for GeographicLib::Geodesic class
4 *
5 * Copyright (c) Charles Karney (2009-2023) <karney@alum.mit.edu> and licensed
6 * under the MIT/X11 License. For more information, see
7 * https://geographiclib.sourceforge.io/
8 *
9 * This is a reformulation of the geodesic problem. The notation is as
10 * follows:
11 * - at a general point (no suffix or 1 or 2 as suffix)
12 * - phi = latitude
13 * - beta = latitude on auxiliary sphere
14 * - omega = longitude on auxiliary sphere
15 * - lambda = longitude
16 * - alpha = azimuth of great circle
17 * - sigma = arc length along great circle
18 * - s = distance
19 * - tau = scaled distance (= sigma at multiples of pi/2)
20 * - at northwards equator crossing
21 * - beta = phi = 0
22 * - omega = lambda = 0
23 * - alpha = alpha0
24 * - sigma = s = 0
25 * - a 12 suffix means a difference, e.g., s12 = s2 - s1.
26 * - s and c prefixes mean sin and cos
27 **********************************************************************/
28
29#include <GeographicLib/Geodesic.hpp>
30#include <GeographicLib/GeodesicLine.hpp>
31
32#if defined(_MSC_VER)
33// Squelch warnings about potentially uninitialized local variables,
34// constant conditional and enum-float expressions and mixing enums
35# pragma warning (disable: 4701 4127 5055 5054)
36#endif
37
38 namespace GeographicLib {
39
40 using namespace std;
41
42 Geodesic::Geodesic(real a, real f, bool exact)
43 : maxit2_(maxit1_ + Math::digits() + 10)
44 // Underflow guard. We require
45 // tiny_ * epsilon() > 0
46 // tiny_ + epsilon() == epsilon()
47 , tiny_(sqrt(numeric_limits<real>::min()))
48 , tol0_(numeric_limits<real>::epsilon())
49 // Increase multiplier in defn of tol1_ from 100 to 200 to fix inverse
50 // case 52.784459512564 0 -52.784459512563990912 179.634407464943777557
51 // which otherwise failed for Visual Studio 10 (Release and Debug)
52 , tol1_(200 * tol0_)
53 , tol2_(sqrt(tol0_))
54 , tolb_(tol0_) // Check on bisection interval
55 , xthresh_(1000 * tol2_)
56 , _a(a)
57 , _f(f)
58 , _exact(exact)
59 , _f1(1 - _f)
60 , _e2(_f * (2 - _f))
61 , _ep2(_e2 / Math::sq(_f1)) // e2 / (1 - e2)
62 , _n(_f / ( 2 - _f))
63 , _b(_a * _f1)
64 , _c2((Math::sq(_a) + Math::sq(_b) *
65 (_e2 == 0 ? 1 :
66 Math::eatanhe(real(1), (_f < 0 ? -1 : 1) * sqrt(fabs(_e2))) / _e2))
67 / 2) // authalic radius squared
68 // The sig12 threshold for "really short". Using the auxiliary sphere
69 // solution with dnm computed at (bet1 + bet2) / 2, the relative error in
70 // the azimuth consistency check is sig12^2 * abs(f) * min(1, 1-f/2) / 2.
71 // (Error measured for 1/100 < b/a < 100 and abs(f) >= 1/1000. For a
72 // given f and sig12, the max error occurs for lines near the pole. If
73 // the old rule for computing dnm = (dn1 + dn2)/2 is used, then the error
74 // increases by a factor of 2.) Setting this equal to epsilon gives
75 // sig12 = etol2. Here 0.1 is a safety factor (error decreased by 100)
76 // and max(0.001, abs(f)) stops etol2 getting too large in the nearly
77 // spherical case.
78 , _etol2(real(0.1) * tol2_ /
79 sqrt( fmax(real(0.001), fabs(_f)) * fmin(real(1), 1 - _f/2) / 2 ))
80 , _geodexact(_exact ? GeodesicExact(a, f) : GeodesicExact())
81 {
82 if (_exact)
83 _c2 = _geodexact._c2;
84 else {
85 if (!(isfinite(_a) && _a > 0))
86 throw GeographicErr("Equatorial radius is not positive");
87 if (!(isfinite(_b) && _b > 0))
88 throw GeographicErr("Polar semi-axis is not positive");
89 A3coeff();
90 C3coeff();
91 C4coeff();
92 }
93 }
94
95 const Geodesic& Geodesic::WGS84() {
96 static const Geodesic wgs84(Constants::WGS84_a(), Constants::WGS84_f());
97 return wgs84;
98 }
99
100 Math::real Geodesic::SinCosSeries(bool sinp,
101 real sinx, real cosx,
102 const real c[], int n) {
103 // Evaluate
104 // y = sinp ? sum(c[i] * sin( 2*i * x), i, 1, n) :
105 // sum(c[i] * cos((2*i+1) * x), i, 0, n-1)
106 // using Clenshaw summation. N.B. c[0] is unused for sin series
107 // Approx operation count = (n + 5) mult and (2 * n + 2) add
108 c += (n + sinp); // Point to one beyond last element
109 real
110 ar = 2 * (cosx - sinx) * (cosx + sinx), // 2 * cos(2 * x)
111 y0 = n & 1 ? *--c : 0, y1 = 0; // accumulators for sum
112 // Now n is even
113 n /= 2;
114 while (n--) {
115 // Unroll loop x 2, so accumulators return to their original role
116 y1 = ar * y0 - y1 + *--c;
117 y0 = ar * y1 - y0 + *--c;
118 }
119 return sinp
120 ? 2 * sinx * cosx * y0 // sin(2 * x) * y0
121 : cosx * (y0 - y1); // cos(x) * (y0 - y1)
122 }
123
124 GeodesicLine Geodesic::Line(real lat1, real lon1, real azi1,
125 unsigned caps) const {
126 return GeodesicLine(*this, lat1, lon1, azi1, caps);
127 }
128
129 Math::real Geodesic::GenDirect(real lat1, real lon1, real azi1,
130 bool arcmode, real s12_a12, unsigned outmask,
131 real& lat2, real& lon2, real& azi2,
132 real& s12, real& m12, real& M12, real& M21,
133 real& S12) const {
134 if (_exact)
135 return _geodexact.GenDirect(lat1, lon1, azi1, arcmode, s12_a12, outmask,
136 lat2, lon2, azi2,
137 s12, m12, M12, M21, S12);
138 // Automatically supply DISTANCE_IN if necessary
139 if (!arcmode) outmask |= DISTANCE_IN;
140 return GeodesicLine(*this, lat1, lon1, azi1, outmask)
141 . // Note the dot!
142 GenPosition(arcmode, s12_a12, outmask,
143 lat2, lon2, azi2, s12, m12, M12, M21, S12);
144 }
145
146 GeodesicLine Geodesic::GenDirectLine(real lat1, real lon1, real azi1,
147 bool arcmode, real s12_a12,
148 unsigned caps) const {
149 azi1 = Math::AngNormalize(azi1);
150 real salp1, calp1;
151 // Guard against underflow in salp0. Also -0 is converted to +0.
152 Math::sincosd(Math::AngRound(azi1), salp1, calp1);
153 // Automatically supply DISTANCE_IN if necessary
154 if (!arcmode) caps |= DISTANCE_IN;
155 return GeodesicLine(*this, lat1, lon1, azi1, salp1, calp1,
156 caps, arcmode, s12_a12);
157 }
158
159 GeodesicLine Geodesic::DirectLine(real lat1, real lon1, real azi1, real s12,
160 unsigned caps) const {
161 return GenDirectLine(lat1, lon1, azi1, false, s12, caps);
162 }
163
164 GeodesicLine Geodesic::ArcDirectLine(real lat1, real lon1, real azi1,
165 real a12, unsigned caps) const {
166 return GenDirectLine(lat1, lon1, azi1, true, a12, caps);
167 }
168
169 Math::real Geodesic::GenInverse(real lat1, real lon1, real lat2, real lon2,
170 unsigned outmask, real& s12,
171 real& salp1, real& calp1,
172 real& salp2, real& calp2,
173 real& m12, real& M12, real& M21,
174 real& S12) const {
175 if (_exact)
176 return _geodexact.GenInverse(lat1, lon1, lat2, lon2,
177 outmask, s12,
178 salp1, calp1, salp2, calp2,
179 m12, M12, M21, S12);
180 // Compute longitude difference (AngDiff does this carefully).
181 using std::isnan; // Needed for Centos 7, ubuntu 14
182 real lon12s, lon12 = Math::AngDiff(lon1, lon2, lon12s);
183 // Make longitude difference positive.
184 int lonsign = signbit(lon12) ? -1 : 1;
185 lon12 *= lonsign; lon12s *= lonsign;
186 real
187 lam12 = lon12 * Math::degree(),
188 slam12, clam12;
189 // Calculate sincos of lon12 + error (this applies AngRound internally).
190 Math::sincosde(lon12, lon12s, slam12, clam12);
191 // the supplementary longitude difference
192 lon12s = (Math::hd - lon12) - lon12s;
193
194 // If really close to the equator, treat as on equator.
195 lat1 = Math::AngRound(Math::LatFix(lat1));
196 lat2 = Math::AngRound(Math::LatFix(lat2));
197 // Swap points so that point with higher (abs) latitude is point 1.
198 // If one latitude is a nan, then it becomes lat1.
199 int swapp = fabs(lat1) < fabs(lat2) || isnan(lat2) ? -1 : 1;
200 if (swapp < 0) {
201 lonsign *= -1;
202 swap(lat1, lat2);
203 }
204 // Make lat1 <= -0
205 int latsign = signbit(lat1) ? 1 : -1;
206 lat1 *= latsign;
207 lat2 *= latsign;
208 // Now we have
209 //
210 // 0 <= lon12 <= 180
211 // -90 <= lat1 <= -0
212 // lat1 <= lat2 <= -lat1
213 //
214 // longsign, swapp, latsign register the transformation to bring the
215 // coordinates to this canonical form. In all cases, 1 means no change was
216 // made. We make these transformations so that there are few cases to
217 // check, e.g., on verifying quadrants in atan2. In addition, this
218 // enforces some symmetries in the results returned.
219
220 real sbet1, cbet1, sbet2, cbet2, s12x, m12x;
221
222 Math::sincosd(lat1, sbet1, cbet1); sbet1 *= _f1;
223 // Ensure cbet1 = +epsilon at poles; doing the fix on beta means that sig12
224 // will be <= 2*tiny for two points at the same pole.
225 Math::norm(sbet1, cbet1); cbet1 = fmax(tiny_, cbet1);
226
227 Math::sincosd(lat2, sbet2, cbet2); sbet2 *= _f1;
228 // Ensure cbet2 = +epsilon at poles
229 Math::norm(sbet2, cbet2); cbet2 = fmax(tiny_, cbet2);
230
231 // If cbet1 < -sbet1, then cbet2 - cbet1 is a sensitive measure of the
232 // |bet1| - |bet2|. Alternatively (cbet1 >= -sbet1), abs(sbet2) + sbet1 is
233 // a better measure. This logic is used in assigning calp2 in Lambda12.
234 // Sometimes these quantities vanish and in that case we force bet2 = +/-
235 // bet1 exactly. An example where is is necessary is the inverse problem
236 // 48.522876735459 0 -48.52287673545898293 179.599720456223079643
237 // which failed with Visual Studio 10 (Release and Debug)
238
239 if (cbet1 < -sbet1) {
240 if (cbet2 == cbet1)
241 sbet2 = copysign(sbet1, sbet2);
242 } else {
243 if (fabs(sbet2) == -sbet1)
244 cbet2 = cbet1;
245 }
246
247 real
248 dn1 = sqrt(1 + _ep2 * Math::sq(sbet1)),
249 dn2 = sqrt(1 + _ep2 * Math::sq(sbet2));
250
251 real a12, sig12;
252 // index zero element of this array is unused
253 real Ca[nC_];
254
255 bool meridian = lat1 == -Math::qd || slam12 == 0;
256
257 if (meridian) {
258
259 // Endpoints are on a single full meridian, so the geodesic might lie on
260 // a meridian.
261
262 calp1 = clam12; salp1 = slam12; // Head to the target longitude
263 calp2 = 1; salp2 = 0; // At the target we're heading north
264
265 real
266 // tan(bet) = tan(sig) * cos(alp)
267 ssig1 = sbet1, csig1 = calp1 * cbet1,
268 ssig2 = sbet2, csig2 = calp2 * cbet2;
269
270 // sig12 = sig2 - sig1
271 sig12 = atan2(fmax(real(0), csig1 * ssig2 - ssig1 * csig2) + real(0),
272 csig1 * csig2 + ssig1 * ssig2);
273 {
274 real dummy;
275 Lengths(_n, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2,
276 outmask | DISTANCE | REDUCEDLENGTH,
277 s12x, m12x, dummy, M12, M21, Ca);
278 }
279 // Add the check for sig12 since zero length geodesics might yield m12 <
280 // 0. Test case was
281 //
282 // echo 20.001 0 20.001 0 | GeodSolve -i
283 //
284 // In fact, we will have sig12 > pi/2 for meridional geodesic which is
285 // not a shortest path.
286 // TODO: investigate m12 < 0 result for aarch/ppc (with -f -p 20)
287 // 20.001000000000001 0.000000000000000 180.000000000000000
288 // 20.001000000000001 0.000000000000000 180.000000000000000
289 // 0.0000000002 0.000000000000001 -0.0000000001
290 // 0.99999999999999989 0.99999999999999989 0.000
291 if (sig12 < 1 || m12x >= 0) {
292 // Need at least 2, to handle 90 0 90 180
293 if (sig12 < 3 * tiny_ ||
294 // Prevent negative s12 or m12 for short lines
295 (sig12 < tol0_ && (s12x < 0 || m12x < 0)))
296 sig12 = m12x = s12x = 0;
297 m12x *= _b;
298 s12x *= _b;
299 a12 = sig12 / Math::degree();
300 } else
301 // m12 < 0, i.e., prolate and too close to anti-podal
302 meridian = false;
303 }
304
305 // somg12 == 2 marks that it needs to be calculated
306 real omg12 = 0, somg12 = 2, comg12 = 0;
307 if (!meridian &&
308 sbet1 == 0 && // and sbet2 == 0
309 (_f <= 0 || lon12s >= _f * Math::hd)) {
310
311 // Geodesic runs along equator
312 calp1 = calp2 = 0; salp1 = salp2 = 1;
313 s12x = _a * lam12;
314 sig12 = omg12 = lam12 / _f1;
315 m12x = _b * sin(sig12);
316 if (outmask & GEODESICSCALE)
317 M12 = M21 = cos(sig12);
318 a12 = lon12 / _f1;
319
320 } else if (!meridian) {
321
322 // Now point1 and point2 belong within a hemisphere bounded by a
323 // meridian and geodesic is neither meridional or equatorial.
324
325 // Figure a starting point for Newton's method
326 real dnm;
327 sig12 = InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2,
328 lam12, slam12, clam12,
329 salp1, calp1, salp2, calp2, dnm,
330 Ca);
331
332 if (sig12 >= 0) {
333 // Short lines (InverseStart sets salp2, calp2, dnm)
334 s12x = sig12 * _b * dnm;
335 m12x = Math::sq(dnm) * _b * sin(sig12 / dnm);
336 if (outmask & GEODESICSCALE)
337 M12 = M21 = cos(sig12 / dnm);
338 a12 = sig12 / Math::degree();
339 omg12 = lam12 / (_f1 * dnm);
340 } else {
341
342 // Newton's method. This is a straightforward solution of f(alp1) =
343 // lambda12(alp1) - lam12 = 0 with one wrinkle. f(alp) has exactly one
344 // root in the interval (0, pi) and its derivative is positive at the
345 // root. Thus f(alp) is positive for alp > alp1 and negative for alp <
346 // alp1. During the course of the iteration, a range (alp1a, alp1b) is
347 // maintained which brackets the root and with each evaluation of
348 // f(alp) the range is shrunk, if possible. Newton's method is
349 // restarted whenever the derivative of f is negative (because the new
350 // value of alp1 is then further from the solution) or if the new
351 // estimate of alp1 lies outside (0,pi); in this case, the new starting
352 // guess is taken to be (alp1a + alp1b) / 2.
353 //
354 // initial values to suppress warnings (if loop is executed 0 times)
355 real ssig1 = 0, csig1 = 0, ssig2 = 0, csig2 = 0, eps = 0, domg12 = 0;
356 unsigned numit = 0;
357 // Bracketing range
358 real salp1a = tiny_, calp1a = 1, salp1b = tiny_, calp1b = -1;
359 for (bool tripn = false, tripb = false;; ++numit) {
360 // the WGS84 test set: mean = 1.47, sd = 1.25, max = 16
361 // WGS84 and random input: mean = 2.85, sd = 0.60
362 real dv;
363 real v = Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1,
364 slam12, clam12,
365 salp2, calp2, sig12, ssig1, csig1, ssig2, csig2,
366 eps, domg12, numit < maxit1_, dv, Ca);
367 if (tripb ||
368 // Reversed test to allow escape with NaNs
369 !(fabs(v) >= (tripn ? 8 : 1) * tol0_) ||
370 // Enough bisections to get accurate result
371 numit == maxit2_)
372 break;
373 // Update bracketing values
374 if (v > 0 && (numit > maxit1_ || calp1/salp1 > calp1b/salp1b))
375 { salp1b = salp1; calp1b = calp1; }
376 else if (v < 0 && (numit > maxit1_ || calp1/salp1 < calp1a/salp1a))
377 { salp1a = salp1; calp1a = calp1; }
378 if (numit < maxit1_ && dv > 0) {
379 real
380 dalp1 = -v/dv;
381 // |dalp1| < pi test moved earlier because GEOGRAPHICLIB_PRECISION
382 // = 5 can result in dalp1 = 10^(10^8). Then sin(dalp1) takes ages
383 // (because of the need to do accurate range reduction).
384 if (fabs(dalp1) < Math::pi()) {
385 real
386 sdalp1 = sin(dalp1), cdalp1 = cos(dalp1),
387 nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
388 if (nsalp1 > 0) {
389 calp1 = calp1 * cdalp1 - salp1 * sdalp1;
390 salp1 = nsalp1;
391 Math::norm(salp1, calp1);
392 // In some regimes we don't get quadratic convergence because
393 // slope -> 0. So use convergence conditions based on epsilon
394 // instead of sqrt(epsilon).
395 tripn = fabs(v) <= 16 * tol0_;
396 continue;
397 }
398 }
399 }
400 // Either dv was not positive or updated value was outside legal
401 // range. Use the midpoint of the bracket as the next estimate.
402 // This mechanism is not needed for the WGS84 ellipsoid, but it does
403 // catch problems with more eccentric ellipsoids. Its efficacy is
404 // such for the WGS84 test set with the starting guess set to alp1 =
405 // 90deg:
406 // the WGS84 test set: mean = 5.21, sd = 3.93, max = 24
407 // WGS84 and random input: mean = 4.74, sd = 0.99
408 salp1 = (salp1a + salp1b)/2;
409 calp1 = (calp1a + calp1b)/2;
410 Math::norm(salp1, calp1);
411 tripn = false;
412 tripb = (fabs(salp1a - salp1) + (calp1a - calp1) < tolb_ ||
413 fabs(salp1 - salp1b) + (calp1 - calp1b) < tolb_);
414 }
415 {
416 real dummy;
417 // Ensure that the reduced length and geodesic scale are computed in
418 // a "canonical" way, with the I2 integral.
419 unsigned lengthmask = outmask |
420 (outmask & (REDUCEDLENGTH | GEODESICSCALE) ? DISTANCE : NONE);
421 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
422 cbet1, cbet2, lengthmask, s12x, m12x, dummy, M12, M21, Ca);
423 }
424 m12x *= _b;
425 s12x *= _b;
426 a12 = sig12 / Math::degree();
427 if (outmask & AREA) {
428 // omg12 = lam12 - domg12
429 real sdomg12 = sin(domg12), cdomg12 = cos(domg12);
430 somg12 = slam12 * cdomg12 - clam12 * sdomg12;
431 comg12 = clam12 * cdomg12 + slam12 * sdomg12;
432 }
433 }
434 }
435
436 if (outmask & DISTANCE)
437 s12 = real(0) + s12x; // Convert -0 to 0
438
439 if (outmask & REDUCEDLENGTH)
440 m12 = real(0) + m12x; // Convert -0 to 0
441
442 if (outmask & AREA) {
443 real
444 // From Lambda12: sin(alp1) * cos(bet1) = sin(alp0)
445 salp0 = salp1 * cbet1,
446 calp0 = hypot(calp1, salp1 * sbet1); // calp0 > 0
447 real alp12;
448 if (calp0 != 0 && salp0 != 0) {
449 real
450 // From Lambda12: tan(bet) = tan(sig) * cos(alp)
451 ssig1 = sbet1, csig1 = calp1 * cbet1,
452 ssig2 = sbet2, csig2 = calp2 * cbet2,
453 k2 = Math::sq(calp0) * _ep2,
454 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2),
455 // Multiplier = a^2 * e^2 * cos(alpha0) * sin(alpha0).
456 A4 = Math::sq(_a) * calp0 * salp0 * _e2;
457 Math::norm(ssig1, csig1);
458 Math::norm(ssig2, csig2);
459 C4f(eps, Ca);
460 real
461 B41 = SinCosSeries(false, ssig1, csig1, Ca, nC4_),
462 B42 = SinCosSeries(false, ssig2, csig2, Ca, nC4_);
463 S12 = A4 * (B42 - B41);
464 } else
465 // Avoid problems with indeterminate sig1, sig2 on equator
466 S12 = 0;
467 if (!meridian && somg12 == 2) {
468 somg12 = sin(omg12); comg12 = cos(omg12);
469 }
470
471 if (!meridian &&
472 // omg12 < 3/4 * pi
473 comg12 > -real(0.7071) && // Long difference not too big
474 sbet2 - sbet1 < real(1.75)) { // Lat difference not too big
475 // Use tan(Gamma/2) = tan(omg12/2)
476 // * (tan(bet1/2)+tan(bet2/2))/(1+tan(bet1/2)*tan(bet2/2))
477 // with tan(x/2) = sin(x)/(1+cos(x))
478 real domg12 = 1 + comg12, dbet1 = 1 + cbet1, dbet2 = 1 + cbet2;
479 alp12 = 2 * atan2( somg12 * ( sbet1 * dbet2 + sbet2 * dbet1 ),
480 domg12 * ( sbet1 * sbet2 + dbet1 * dbet2 ) );
481 } else {
482 // alp12 = alp2 - alp1, used in atan2 so no need to normalize
483 real
484 salp12 = salp2 * calp1 - calp2 * salp1,
485 calp12 = calp2 * calp1 + salp2 * salp1;
486 // The right thing appears to happen if alp1 = +/-180 and alp2 = 0, viz
487 // salp12 = -0 and alp12 = -180. However this depends on the sign
488 // being attached to 0 correctly. The following ensures the correct
489 // behavior.
490 if (salp12 == 0 && calp12 < 0) {
491 salp12 = tiny_ * calp1;
492 calp12 = -1;
493 }
494 alp12 = atan2(salp12, calp12);
495 }
496 S12 += _c2 * alp12;
497 S12 *= swapp * lonsign * latsign;
498 // Convert -0 to 0
499 S12 += 0;
500 }
501
502 // Convert calp, salp to azimuth accounting for lonsign, swapp, latsign.
503 if (swapp < 0) {
504 swap(salp1, salp2);
505 swap(calp1, calp2);
506 if (outmask & GEODESICSCALE)
507 swap(M12, M21);
508 }
509
510 salp1 *= swapp * lonsign; calp1 *= swapp * latsign;
511 salp2 *= swapp * lonsign; calp2 *= swapp * latsign;
512 // Returned value in [0, 180]
513 return a12;
514 }
515
516 Math::real Geodesic::GenInverse(real lat1, real lon1, real lat2, real lon2,
517 unsigned outmask,
518 real& s12, real& azi1, real& azi2,
519 real& m12, real& M12, real& M21,
520 real& S12) const {
521 outmask &= OUT_MASK;
522 real salp1, calp1, salp2, calp2,
523 a12 = GenInverse(lat1, lon1, lat2, lon2,
524 outmask, s12, salp1, calp1, salp2, calp2,
525 m12, M12, M21, S12);
526 if (outmask & AZIMUTH) {
527 azi1 = Math::atan2d(salp1, calp1);
528 azi2 = Math::atan2d(salp2, calp2);
529 }
530 return a12;
531 }
532
533 GeodesicLine Geodesic::InverseLine(real lat1, real lon1,
534 real lat2, real lon2,
535 unsigned caps) const {
536 real t, salp1, calp1, salp2, calp2,
537 a12 = GenInverse(lat1, lon1, lat2, lon2,
538 // No need to specify AZIMUTH here
539 0u, t, salp1, calp1, salp2, calp2,
540 t, t, t, t),
541 azi1 = Math::atan2d(salp1, calp1);
542 // Ensure that a12 can be converted to a distance
543 if (caps & (OUT_MASK & DISTANCE_IN)) caps |= DISTANCE;
544 return
545 GeodesicLine(*this, lat1, lon1, azi1, salp1, calp1, caps, true, a12);
546 }
547
548 void Geodesic::Lengths(real eps, real sig12,
549 real ssig1, real csig1, real dn1,
550 real ssig2, real csig2, real dn2,
551 real cbet1, real cbet2, unsigned outmask,
552 real& s12b, real& m12b, real& m0,
553 real& M12, real& M21,
554 // Scratch area of the right size
555 real Ca[]) const {
556 // Return m12b = (reduced length)/_b; also calculate s12b = distance/_b,
557 // and m0 = coefficient of secular term in expression for reduced length.
558
559 outmask &= OUT_MASK;
560 // outmask & DISTANCE: set s12b
561 // outmask & REDUCEDLENGTH: set m12b & m0
562 // outmask & GEODESICSCALE: set M12 & M21
563
564 real m0x = 0, J12 = 0, A1 = 0, A2 = 0;
565 real Cb[nC2_ + 1];
566 if (outmask & (DISTANCE | REDUCEDLENGTH | GEODESICSCALE)) {
567 A1 = A1m1f(eps);
568 C1f(eps, Ca);
569 if (outmask & (REDUCEDLENGTH | GEODESICSCALE)) {
570 A2 = A2m1f(eps);
571 C2f(eps, Cb);
572 m0x = A1 - A2;
573 A2 = 1 + A2;
574 }
575 A1 = 1 + A1;
576 }
577 if (outmask & DISTANCE) {
578 real B1 = SinCosSeries(true, ssig2, csig2, Ca, nC1_) -
579 SinCosSeries(true, ssig1, csig1, Ca, nC1_);
580 // Missing a factor of _b
581 s12b = A1 * (sig12 + B1);
582 if (outmask & (REDUCEDLENGTH | GEODESICSCALE)) {
583 real B2 = SinCosSeries(true, ssig2, csig2, Cb, nC2_) -
584 SinCosSeries(true, ssig1, csig1, Cb, nC2_);
585 J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
586 }
587 } else if (outmask & (REDUCEDLENGTH | GEODESICSCALE)) {
588 // Assume here that nC1_ >= nC2_
589 for (int l = 1; l <= nC2_; ++l)
590 Cb[l] = A1 * Ca[l] - A2 * Cb[l];
591 J12 = m0x * sig12 + (SinCosSeries(true, ssig2, csig2, Cb, nC2_) -
592 SinCosSeries(true, ssig1, csig1, Cb, nC2_));
593 }
594 if (outmask & REDUCEDLENGTH) {
595 m0 = m0x;
596 // Missing a factor of _b.
597 // Add parens around (csig1 * ssig2) and (ssig1 * csig2) to ensure
598 // accurate cancellation in the case of coincident points.
599 m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) -
600 csig1 * csig2 * J12;
601 }
602 if (outmask & GEODESICSCALE) {
603 real csig12 = csig1 * csig2 + ssig1 * ssig2;
604 real t = _ep2 * (cbet1 - cbet2) * (cbet1 + cbet2) / (dn1 + dn2);
605 M12 = csig12 + (t * ssig2 - csig2 * J12) * ssig1 / dn1;
606 M21 = csig12 - (t * ssig1 - csig1 * J12) * ssig2 / dn2;
607 }
608 }
609
610 Math::real Geodesic::Astroid(real x, real y) {
611 // Solve k^4+2*k^3-(x^2+y^2-1)*k^2-2*y^2*k-y^2 = 0 for positive root k.
612 // This solution is adapted from Geocentric::Reverse.
613 real k;
614 real
615 p = Math::sq(x),
616 q = Math::sq(y),
617 r = (p + q - 1) / 6;
618 if ( !(q == 0 && r <= 0) ) {
619 real
620 // Avoid possible division by zero when r = 0 by multiplying equations
621 // for s and t by r^3 and r, resp.
622 S = p * q / 4, // S = r^3 * s
623 r2 = Math::sq(r),
624 r3 = r * r2,
625 // The discriminant of the quadratic equation for T3. This is zero on
626 // the evolute curve p^(1/3)+q^(1/3) = 1
627 disc = S * (S + 2 * r3);
628 real u = r;
629 if (disc >= 0) {
630 real T3 = S + r3;
631 // Pick the sign on the sqrt to maximize abs(T3). This minimizes loss
632 // of precision due to cancellation. The result is unchanged because
633 // of the way the T is used in definition of u.
634 T3 += T3 < 0 ? -sqrt(disc) : sqrt(disc); // T3 = (r * t)^3
635 // N.B. cbrt always returns the real root. cbrt(-8) = -2.
636 real T = cbrt(T3); // T = r * t
637 // T can be zero; but then r2 / T -> 0.
638 u += T + (T != 0 ? r2 / T : 0);
639 } else {
640 // T is complex, but the way u is defined the result is real.
641 real ang = atan2(sqrt(-disc), -(S + r3));
642 // There are three possible cube roots. We choose the root which
643 // avoids cancellation. Note that disc < 0 implies that r < 0.
644 u += 2 * r * cos(ang / 3);
645 }
646 real
647 v = sqrt(Math::sq(u) + q), // guaranteed positive
648 // Avoid loss of accuracy when u < 0.
649 uv = u < 0 ? q / (v - u) : u + v, // u+v, guaranteed positive
650 w = (uv - q) / (2 * v); // positive?
651 // Rearrange expression for k to avoid loss of accuracy due to
652 // subtraction. Division by 0 not possible because uv > 0, w >= 0.
653 k = uv / (sqrt(uv + Math::sq(w)) + w); // guaranteed positive
654 } else { // q == 0 && r <= 0
655 // y = 0 with |x| <= 1. Handle this case directly.
656 // for y small, positive root is k = abs(y)/sqrt(1-x^2)
657 k = 0;
658 }
659 return k;
660 }
661
662 Math::real Geodesic::InverseStart(real sbet1, real cbet1, real dn1,
663 real sbet2, real cbet2, real dn2,
664 real lam12, real slam12, real clam12,
665 real& salp1, real& calp1,
666 // Only updated if return val >= 0
667 real& salp2, real& calp2,
668 // Only updated for short lines
669 real& dnm,
670 // Scratch area of the right size
671 real Ca[]) const {
672 // Return a starting point for Newton's method in salp1 and calp1 (function
673 // value is -1). If Newton's method doesn't need to be used, return also
674 // salp2 and calp2 and function value is sig12.
675 real
676 sig12 = -1, // Return value
677 // bet12 = bet2 - bet1 in [0, pi); bet12a = bet2 + bet1 in (-pi, 0]
678 sbet12 = sbet2 * cbet1 - cbet2 * sbet1,
679 cbet12 = cbet2 * cbet1 + sbet2 * sbet1;
680 real sbet12a = sbet2 * cbet1 + cbet2 * sbet1;
681 bool shortline = cbet12 >= 0 && sbet12 < real(0.5) &&
682 cbet2 * lam12 < real(0.5);
683 real somg12, comg12;
684 if (shortline) {
685 real sbetm2 = Math::sq(sbet1 + sbet2);
686 // sin((bet1+bet2)/2)^2
687 // = (sbet1 + sbet2)^2 / ((sbet1 + sbet2)^2 + (cbet1 + cbet2)^2)
688 sbetm2 /= sbetm2 + Math::sq(cbet1 + cbet2);
689 dnm = sqrt(1 + _ep2 * sbetm2);
690 real omg12 = lam12 / (_f1 * dnm);
691 somg12 = sin(omg12); comg12 = cos(omg12);
692 } else {
693 somg12 = slam12; comg12 = clam12;
694 }
695
696 salp1 = cbet2 * somg12;
697 calp1 = comg12 >= 0 ?
698 sbet12 + cbet2 * sbet1 * Math::sq(somg12) / (1 + comg12) :
699 sbet12a - cbet2 * sbet1 * Math::sq(somg12) / (1 - comg12);
700
701 real
702 ssig12 = hypot(salp1, calp1),
703 csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
704
705 if (shortline && ssig12 < _etol2) {
706 // really short lines
707 salp2 = cbet1 * somg12;
708 calp2 = sbet12 - cbet1 * sbet2 *
709 (comg12 >= 0 ? Math::sq(somg12) / (1 + comg12) : 1 - comg12);
710 Math::norm(salp2, calp2);
711 // Set return value
712 sig12 = atan2(ssig12, csig12);
713 } else if (fabs(_n) > real(0.1) || // Skip astroid calc if too eccentric
714 csig12 >= 0 ||
715 ssig12 >= 6 * fabs(_n) * Math::pi() * Math::sq(cbet1)) {
716 // Nothing to do, zeroth order spherical approximation is OK
717 } else {
718 // Scale lam12 and bet2 to x, y coordinate system where antipodal point
719 // is at origin and singular point is at y = 0, x = -1.
720 real x, y, lamscale, betscale;
721 real lam12x = atan2(-slam12, -clam12); // lam12 - pi
722 if (_f >= 0) { // In fact f == 0 does not get here
723 // x = dlong, y = dlat
724 {
725 real
726 k2 = Math::sq(sbet1) * _ep2,
727 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
728 lamscale = _f * cbet1 * A3f(eps) * Math::pi();
729 }
730 betscale = lamscale * cbet1;
731
732 x = lam12x / lamscale;
733 y = sbet12a / betscale;
734 } else { // _f < 0
735 // x = dlat, y = dlong
736 real
737 cbet12a = cbet2 * cbet1 - sbet2 * sbet1,
738 bet12a = atan2(sbet12a, cbet12a);
739 real m12b, m0, dummy;
740 // In the case of lon12 = 180, this repeats a calculation made in
741 // Inverse.
742 Lengths(_n, Math::pi() + bet12a,
743 sbet1, -cbet1, dn1, sbet2, cbet2, dn2,
744 cbet1, cbet2,
745 REDUCEDLENGTH, dummy, m12b, m0, dummy, dummy, Ca);
746 x = -1 + m12b / (cbet1 * cbet2 * m0 * Math::pi());
747 betscale = x < -real(0.01) ? sbet12a / x :
748 -_f * Math::sq(cbet1) * Math::pi();
749 lamscale = betscale / cbet1;
750 y = lam12x / lamscale;
751 }
752
753 if (y > -tol1_ && x > -1 - xthresh_) {
754 // strip near cut
755 // Need real(x) here to cast away the volatility of x for min/max
756 if (_f >= 0) {
757 salp1 = fmin(real(1), -x); calp1 = - sqrt(1 - Math::sq(salp1));
758 } else {
759 calp1 = fmax(real(x > -tol1_ ? 0 : -1), x);
760 salp1 = sqrt(1 - Math::sq(calp1));
761 }
762 } else {
763 // Estimate alp1, by solving the astroid problem.
764 //
765 // Could estimate alpha1 = theta + pi/2, directly, i.e.,
766 // calp1 = y/k; salp1 = -x/(1+k); for _f >= 0
767 // calp1 = x/(1+k); salp1 = -y/k; for _f < 0 (need to check)
768 //
769 // However, it's better to estimate omg12 from astroid and use
770 // spherical formula to compute alp1. This reduces the mean number of
771 // Newton iterations for astroid cases from 2.24 (min 0, max 6) to 2.12
772 // (min 0 max 5). The changes in the number of iterations are as
773 // follows:
774 //
775 // change percent
776 // 1 5
777 // 0 78
778 // -1 16
779 // -2 0.6
780 // -3 0.04
781 // -4 0.002
782 //
783 // The histogram of iterations is (m = number of iterations estimating
784 // alp1 directly, n = number of iterations estimating via omg12, total
785 // number of trials = 148605):
786 //
787 // iter m n
788 // 0 148 186
789 // 1 13046 13845
790 // 2 93315 102225
791 // 3 36189 32341
792 // 4 5396 7
793 // 5 455 1
794 // 6 56 0
795 //
796 // Because omg12 is near pi, estimate work with omg12a = pi - omg12
797 real k = Astroid(x, y);
798 real
799 omg12a = lamscale * ( _f >= 0 ? -x * k/(1 + k) : -y * (1 + k)/k );
800 somg12 = sin(omg12a); comg12 = -cos(omg12a);
801 // Update spherical estimate of alp1 using omg12 instead of lam12
802 salp1 = cbet2 * somg12;
803 calp1 = sbet12a - cbet2 * sbet1 * Math::sq(somg12) / (1 - comg12);
804 }
805 }
806 // Sanity check on starting guess. Backwards check allows NaN through.
807 if (!(salp1 <= 0))
808 Math::norm(salp1, calp1);
809 else {
810 salp1 = 1; calp1 = 0;
811 }
812 return sig12;
813 }
814
815 Math::real Geodesic::Lambda12(real sbet1, real cbet1, real dn1,
816 real sbet2, real cbet2, real dn2,
817 real salp1, real calp1,
818 real slam120, real clam120,
819 real& salp2, real& calp2,
820 real& sig12,
821 real& ssig1, real& csig1,
822 real& ssig2, real& csig2,
823 real& eps, real& domg12,
824 bool diffp, real& dlam12,
825 // Scratch area of the right size
826 real Ca[]) const {
827
828 if (sbet1 == 0 && calp1 == 0)
829 // Break degeneracy of equatorial line. This case has already been
830 // handled.
831 calp1 = -tiny_;
832
833 real
834 // sin(alp1) * cos(bet1) = sin(alp0)
835 salp0 = salp1 * cbet1,
836 calp0 = hypot(calp1, salp1 * sbet1); // calp0 > 0
837
838 real somg1, comg1, somg2, comg2, somg12, comg12, lam12;
839 // tan(bet1) = tan(sig1) * cos(alp1)
840 // tan(omg1) = sin(alp0) * tan(sig1) = tan(omg1)=tan(alp1)*sin(bet1)
841 ssig1 = sbet1; somg1 = salp0 * sbet1;
842 csig1 = comg1 = calp1 * cbet1;
843 Math::norm(ssig1, csig1);
844 // Math::norm(somg1, comg1); -- don't need to normalize!
845
846 // Enforce symmetries in the case abs(bet2) = -bet1. Need to be careful
847 // about this case, since this can yield singularities in the Newton
848 // iteration.
849 // sin(alp2) * cos(bet2) = sin(alp0)
850 salp2 = cbet2 != cbet1 ? salp0 / cbet2 : salp1;
851 // calp2 = sqrt(1 - sq(salp2))
852 // = sqrt(sq(calp0) - sq(sbet2)) / cbet2
853 // and subst for calp0 and rearrange to give (choose positive sqrt
854 // to give alp2 in [0, pi/2]).
855 calp2 = cbet2 != cbet1 || fabs(sbet2) != -sbet1 ?
856 sqrt(Math::sq(calp1 * cbet1) +
857 (cbet1 < -sbet1 ?
858 (cbet2 - cbet1) * (cbet1 + cbet2) :
859 (sbet1 - sbet2) * (sbet1 + sbet2))) / cbet2 :
860 fabs(calp1);
861 // tan(bet2) = tan(sig2) * cos(alp2)
862 // tan(omg2) = sin(alp0) * tan(sig2).
863 ssig2 = sbet2; somg2 = salp0 * sbet2;
864 csig2 = comg2 = calp2 * cbet2;
865 Math::norm(ssig2, csig2);
866 // Math::norm(somg2, comg2); -- don't need to normalize!
867
868 // sig12 = sig2 - sig1, limit to [0, pi]
869 sig12 = atan2(fmax(real(0), csig1 * ssig2 - ssig1 * csig2) + real(0),
870 csig1 * csig2 + ssig1 * ssig2);
871
872 // omg12 = omg2 - omg1, limit to [0, pi]
873 somg12 = fmax(real(0), comg1 * somg2 - somg1 * comg2) + real(0);
874 comg12 = comg1 * comg2 + somg1 * somg2;
875 // eta = omg12 - lam120
876 real eta = atan2(somg12 * clam120 - comg12 * slam120,
877 comg12 * clam120 + somg12 * slam120);
878 real B312;
879 real k2 = Math::sq(calp0) * _ep2;
880 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
881 C3f(eps, Ca);
882 B312 = (SinCosSeries(true, ssig2, csig2, Ca, nC3_-1) -
883 SinCosSeries(true, ssig1, csig1, Ca, nC3_-1));
884 domg12 = -_f * A3f(eps) * salp0 * (sig12 + B312);
885 lam12 = eta + domg12;
886
887 if (diffp) {
888 if (calp2 == 0)
889 dlam12 = - 2 * _f1 * dn1 / sbet1;
890 else {
891 real dummy;
892 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
893 cbet1, cbet2, REDUCEDLENGTH,
894 dummy, dlam12, dummy, dummy, dummy, Ca);
895 dlam12 *= _f1 / (calp2 * cbet2);
896 }
897 }
898
899 return lam12;
900 }
901
902 Math::real Geodesic::A3f(real eps) const {
903 // Evaluate A3
904 return Math::polyval(nA3_ - 1, _aA3x, eps);
905 }
906
907 void Geodesic::C3f(real eps, real c[]) const {
908 // Evaluate C3 coeffs
909 // Elements c[1] thru c[nC3_ - 1] are set
910 real mult = 1;
911 int o = 0;
912 for (int l = 1; l < nC3_; ++l) { // l is index of C3[l]
913 int m = nC3_ - l - 1; // order of polynomial in eps
914 mult *= eps;
915 c[l] = mult * Math::polyval(m, _cC3x + o, eps);
916 o += m + 1;
917 }
918 // Post condition: o == nC3x_
919 }
920
921 void Geodesic::C4f(real eps, real c[]) const {
922 // Evaluate C4 coeffs
923 // Elements c[0] thru c[nC4_ - 1] are set
924 real mult = 1;
925 int o = 0;
926 for (int l = 0; l < nC4_; ++l) { // l is index of C4[l]
927 int m = nC4_ - l - 1; // order of polynomial in eps
928 c[l] = mult * Math::polyval(m, _cC4x + o, eps);
929 o += m + 1;
930 mult *= eps;
931 }
932 // Post condition: o == nC4x_
933 }
934
935 // The static const coefficient arrays in the following functions are
936 // generated by Maxima and give the coefficients of the Taylor expansions for
937 // the geodesics. The convention on the order of these coefficients is as
938 // follows:
939 //
940 // ascending order in the trigonometric expansion,
941 // then powers of eps in descending order,
942 // finally powers of n in descending order.
943 //
944 // (For some expansions, only a subset of levels occur.) For each polynomial
945 // of order n at the lowest level, the (n+1) coefficients of the polynomial
946 // are followed by a divisor which is applied to the whole polynomial. In
947 // this way, the coefficients are expressible with no round off error. The
948 // sizes of the coefficient arrays are:
949 //
950 // A1m1f, A2m1f = floor(N/2) + 2
951 // C1f, C1pf, C2f, A3coeff = (N^2 + 7*N - 2*floor(N/2)) / 4
952 // C3coeff = (N - 1) * (N^2 + 7*N - 2*floor(N/2)) / 8
953 // C4coeff = N * (N + 1) * (N + 5) / 6
954 //
955 // where N = GEOGRAPHICLIB_GEODESIC_ORDER
956 // = nA1 = nA2 = nC1 = nC1p = nA3 = nC4
957
958 // The scale factor A1-1 = mean value of (d/dsigma)I1 - 1
959 Math::real Geodesic::A1m1f(real eps) {
960 // Generated by Maxima on 2015-05-05 18:08:12-04:00
961#if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1
962 static const real coeff[] = {
963 // (1-eps)*A1-1, polynomial in eps2 of order 1
964 1, 0, 4,
965 };
966#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2
967 static const real coeff[] = {
968 // (1-eps)*A1-1, polynomial in eps2 of order 2
969 1, 16, 0, 64,
970 };
971#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3
972 static const real coeff[] = {
973 // (1-eps)*A1-1, polynomial in eps2 of order 3
974 1, 4, 64, 0, 256,
975 };
976#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4
977 static const real coeff[] = {
978 // (1-eps)*A1-1, polynomial in eps2 of order 4
979 25, 64, 256, 4096, 0, 16384,
980 };
981#else
982#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
983#endif
984 static_assert(sizeof(coeff) / sizeof(real) == nA1_/2 + 2,
985 "Coefficient array size mismatch in A1m1f");
986 int m = nA1_/2;
987 real t = Math::polyval(m, coeff, Math::sq(eps)) / coeff[m + 1];
988 return (t + eps) / (1 - eps);
989 }
990
991 // The coefficients C1[l] in the Fourier expansion of B1
992 void Geodesic::C1f(real eps, real c[]) {
993 // Generated by Maxima on 2015-05-05 18:08:12-04:00
994#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
995 static const real coeff[] = {
996 // C1[1]/eps^1, polynomial in eps2 of order 1
997 3, -8, 16,
998 // C1[2]/eps^2, polynomial in eps2 of order 0
999 -1, 16,
1000 // C1[3]/eps^3, polynomial in eps2 of order 0
1001 -1, 48,
1002 };
1003#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1004 static const real coeff[] = {
1005 // C1[1]/eps^1, polynomial in eps2 of order 1
1006 3, -8, 16,
1007 // C1[2]/eps^2, polynomial in eps2 of order 1
1008 1, -2, 32,
1009 // C1[3]/eps^3, polynomial in eps2 of order 0
1010 -1, 48,
1011 // C1[4]/eps^4, polynomial in eps2 of order 0
1012 -5, 512,
1013 };
1014#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1015 static const real coeff[] = {
1016 // C1[1]/eps^1, polynomial in eps2 of order 2
1017 -1, 6, -16, 32,
1018 // C1[2]/eps^2, polynomial in eps2 of order 1
1019 1, -2, 32,
1020 // C1[3]/eps^3, polynomial in eps2 of order 1
1021 9, -16, 768,
1022 // C1[4]/eps^4, polynomial in eps2 of order 0
1023 -5, 512,
1024 // C1[5]/eps^5, polynomial in eps2 of order 0
1025 -7, 1280,
1026 };
1027#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1028 static const real coeff[] = {
1029 // C1[1]/eps^1, polynomial in eps2 of order 2
1030 -1, 6, -16, 32,
1031 // C1[2]/eps^2, polynomial in eps2 of order 2
1032 -9, 64, -128, 2048,
1033 // C1[3]/eps^3, polynomial in eps2 of order 1
1034 9, -16, 768,
1035 // C1[4]/eps^4, polynomial in eps2 of order 1
1036 3, -5, 512,
1037 // C1[5]/eps^5, polynomial in eps2 of order 0
1038 -7, 1280,
1039 // C1[6]/eps^6, polynomial in eps2 of order 0
1040 -7, 2048,
1041 };
1042#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1043 static const real coeff[] = {
1044 // C1[1]/eps^1, polynomial in eps2 of order 3
1045 19, -64, 384, -1024, 2048,
1046 // C1[2]/eps^2, polynomial in eps2 of order 2
1047 -9, 64, -128, 2048,
1048 // C1[3]/eps^3, polynomial in eps2 of order 2
1049 -9, 72, -128, 6144,
1050 // C1[4]/eps^4, polynomial in eps2 of order 1
1051 3, -5, 512,
1052 // C1[5]/eps^5, polynomial in eps2 of order 1
1053 35, -56, 10240,
1054 // C1[6]/eps^6, polynomial in eps2 of order 0
1055 -7, 2048,
1056 // C1[7]/eps^7, polynomial in eps2 of order 0
1057 -33, 14336,
1058 };
1059#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1060 static const real coeff[] = {
1061 // C1[1]/eps^1, polynomial in eps2 of order 3
1062 19, -64, 384, -1024, 2048,
1063 // C1[2]/eps^2, polynomial in eps2 of order 3
1064 7, -18, 128, -256, 4096,
1065 // C1[3]/eps^3, polynomial in eps2 of order 2
1066 -9, 72, -128, 6144,
1067 // C1[4]/eps^4, polynomial in eps2 of order 2
1068 -11, 96, -160, 16384,
1069 // C1[5]/eps^5, polynomial in eps2 of order 1
1070 35, -56, 10240,
1071 // C1[6]/eps^6, polynomial in eps2 of order 1
1072 9, -14, 4096,
1073 // C1[7]/eps^7, polynomial in eps2 of order 0
1074 -33, 14336,
1075 // C1[8]/eps^8, polynomial in eps2 of order 0
1076 -429, 262144,
1077 };
1078#else
1079#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1080#endif
1081 static_assert(sizeof(coeff) / sizeof(real) ==
1082 (nC1_*nC1_ + 7*nC1_ - 2*(nC1_/2)) / 4,
1083 "Coefficient array size mismatch in C1f");
1084 real
1085 eps2 = Math::sq(eps),
1086 d = eps;
1087 int o = 0;
1088 for (int l = 1; l <= nC1_; ++l) { // l is index of C1p[l]
1089 int m = (nC1_ - l) / 2; // order of polynomial in eps^2
1090 c[l] = d * Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1091 o += m + 2;
1092 d *= eps;
1093 }
1094 // Post condition: o == sizeof(coeff) / sizeof(real)
1095 }
1096
1097 // The coefficients C1p[l] in the Fourier expansion of B1p
1098 void Geodesic::C1pf(real eps, real c[]) {
1099 // Generated by Maxima on 2015-05-05 18:08:12-04:00
1100#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1101 static const real coeff[] = {
1102 // C1p[1]/eps^1, polynomial in eps2 of order 1
1103 -9, 16, 32,
1104 // C1p[2]/eps^2, polynomial in eps2 of order 0
1105 5, 16,
1106 // C1p[3]/eps^3, polynomial in eps2 of order 0
1107 29, 96,
1108 };
1109#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1110 static const real coeff[] = {
1111 // C1p[1]/eps^1, polynomial in eps2 of order 1
1112 -9, 16, 32,
1113 // C1p[2]/eps^2, polynomial in eps2 of order 1
1114 -37, 30, 96,
1115 // C1p[3]/eps^3, polynomial in eps2 of order 0
1116 29, 96,
1117 // C1p[4]/eps^4, polynomial in eps2 of order 0
1118 539, 1536,
1119 };
1120#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1121 static const real coeff[] = {
1122 // C1p[1]/eps^1, polynomial in eps2 of order 2
1123 205, -432, 768, 1536,
1124 // C1p[2]/eps^2, polynomial in eps2 of order 1
1125 -37, 30, 96,
1126 // C1p[3]/eps^3, polynomial in eps2 of order 1
1127 -225, 116, 384,
1128 // C1p[4]/eps^4, polynomial in eps2 of order 0
1129 539, 1536,
1130 // C1p[5]/eps^5, polynomial in eps2 of order 0
1131 3467, 7680,
1132 };
1133#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1134 static const real coeff[] = {
1135 // C1p[1]/eps^1, polynomial in eps2 of order 2
1136 205, -432, 768, 1536,
1137 // C1p[2]/eps^2, polynomial in eps2 of order 2
1138 4005, -4736, 3840, 12288,
1139 // C1p[3]/eps^3, polynomial in eps2 of order 1
1140 -225, 116, 384,
1141 // C1p[4]/eps^4, polynomial in eps2 of order 1
1142 -7173, 2695, 7680,
1143 // C1p[5]/eps^5, polynomial in eps2 of order 0
1144 3467, 7680,
1145 // C1p[6]/eps^6, polynomial in eps2 of order 0
1146 38081, 61440,
1147 };
1148#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1149 static const real coeff[] = {
1150 // C1p[1]/eps^1, polynomial in eps2 of order 3
1151 -4879, 9840, -20736, 36864, 73728,
1152 // C1p[2]/eps^2, polynomial in eps2 of order 2
1153 4005, -4736, 3840, 12288,
1154 // C1p[3]/eps^3, polynomial in eps2 of order 2
1155 8703, -7200, 3712, 12288,
1156 // C1p[4]/eps^4, polynomial in eps2 of order 1
1157 -7173, 2695, 7680,
1158 // C1p[5]/eps^5, polynomial in eps2 of order 1
1159 -141115, 41604, 92160,
1160 // C1p[6]/eps^6, polynomial in eps2 of order 0
1161 38081, 61440,
1162 // C1p[7]/eps^7, polynomial in eps2 of order 0
1163 459485, 516096,
1164 };
1165#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1166 static const real coeff[] = {
1167 // C1p[1]/eps^1, polynomial in eps2 of order 3
1168 -4879, 9840, -20736, 36864, 73728,
1169 // C1p[2]/eps^2, polynomial in eps2 of order 3
1170 -86171, 120150, -142080, 115200, 368640,
1171 // C1p[3]/eps^3, polynomial in eps2 of order 2
1172 8703, -7200, 3712, 12288,
1173 // C1p[4]/eps^4, polynomial in eps2 of order 2
1174 1082857, -688608, 258720, 737280,
1175 // C1p[5]/eps^5, polynomial in eps2 of order 1
1176 -141115, 41604, 92160,
1177 // C1p[6]/eps^6, polynomial in eps2 of order 1
1178 -2200311, 533134, 860160,
1179 // C1p[7]/eps^7, polynomial in eps2 of order 0
1180 459485, 516096,
1181 // C1p[8]/eps^8, polynomial in eps2 of order 0
1182 109167851, 82575360,
1183 };
1184#else
1185#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1186#endif
1187 static_assert(sizeof(coeff) / sizeof(real) ==
1188 (nC1p_*nC1p_ + 7*nC1p_ - 2*(nC1p_/2)) / 4,
1189 "Coefficient array size mismatch in C1pf");
1190 real
1191 eps2 = Math::sq(eps),
1192 d = eps;
1193 int o = 0;
1194 for (int l = 1; l <= nC1p_; ++l) { // l is index of C1p[l]
1195 int m = (nC1p_ - l) / 2; // order of polynomial in eps^2
1196 c[l] = d * Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1197 o += m + 2;
1198 d *= eps;
1199 }
1200 // Post condition: o == sizeof(coeff) / sizeof(real)
1201 }
1202
1203 // The scale factor A2-1 = mean value of (d/dsigma)I2 - 1
1204 Math::real Geodesic::A2m1f(real eps) {
1205 // Generated by Maxima on 2015-05-29 08:09:47-04:00
1206#if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1
1207 static const real coeff[] = {
1208 // (eps+1)*A2-1, polynomial in eps2 of order 1
1209 -3, 0, 4,
1210 }; // count = 3
1211#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2
1212 static const real coeff[] = {
1213 // (eps+1)*A2-1, polynomial in eps2 of order 2
1214 -7, -48, 0, 64,
1215 }; // count = 4
1216#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3
1217 static const real coeff[] = {
1218 // (eps+1)*A2-1, polynomial in eps2 of order 3
1219 -11, -28, -192, 0, 256,
1220 }; // count = 5
1221#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4
1222 static const real coeff[] = {
1223 // (eps+1)*A2-1, polynomial in eps2 of order 4
1224 -375, -704, -1792, -12288, 0, 16384,
1225 }; // count = 6
1226#else
1227#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1228#endif
1229 static_assert(sizeof(coeff) / sizeof(real) == nA2_/2 + 2,
1230 "Coefficient array size mismatch in A2m1f");
1231 int m = nA2_/2;
1232 real t = Math::polyval(m, coeff, Math::sq(eps)) / coeff[m + 1];
1233 return (t - eps) / (1 + eps);
1234 }
1235
1236 // The coefficients C2[l] in the Fourier expansion of B2
1237 void Geodesic::C2f(real eps, real c[]) {
1238 // Generated by Maxima on 2015-05-05 18:08:12-04:00
1239#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1240 static const real coeff[] = {
1241 // C2[1]/eps^1, polynomial in eps2 of order 1
1242 1, 8, 16,
1243 // C2[2]/eps^2, polynomial in eps2 of order 0
1244 3, 16,
1245 // C2[3]/eps^3, polynomial in eps2 of order 0
1246 5, 48,
1247 };
1248#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1249 static const real coeff[] = {
1250 // C2[1]/eps^1, polynomial in eps2 of order 1
1251 1, 8, 16,
1252 // C2[2]/eps^2, polynomial in eps2 of order 1
1253 1, 6, 32,
1254 // C2[3]/eps^3, polynomial in eps2 of order 0
1255 5, 48,
1256 // C2[4]/eps^4, polynomial in eps2 of order 0
1257 35, 512,
1258 };
1259#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1260 static const real coeff[] = {
1261 // C2[1]/eps^1, polynomial in eps2 of order 2
1262 1, 2, 16, 32,
1263 // C2[2]/eps^2, polynomial in eps2 of order 1
1264 1, 6, 32,
1265 // C2[3]/eps^3, polynomial in eps2 of order 1
1266 15, 80, 768,
1267 // C2[4]/eps^4, polynomial in eps2 of order 0
1268 35, 512,
1269 // C2[5]/eps^5, polynomial in eps2 of order 0
1270 63, 1280,
1271 };
1272#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1273 static const real coeff[] = {
1274 // C2[1]/eps^1, polynomial in eps2 of order 2
1275 1, 2, 16, 32,
1276 // C2[2]/eps^2, polynomial in eps2 of order 2
1277 35, 64, 384, 2048,
1278 // C2[3]/eps^3, polynomial in eps2 of order 1
1279 15, 80, 768,
1280 // C2[4]/eps^4, polynomial in eps2 of order 1
1281 7, 35, 512,
1282 // C2[5]/eps^5, polynomial in eps2 of order 0
1283 63, 1280,
1284 // C2[6]/eps^6, polynomial in eps2 of order 0
1285 77, 2048,
1286 };
1287#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1288 static const real coeff[] = {
1289 // C2[1]/eps^1, polynomial in eps2 of order 3
1290 41, 64, 128, 1024, 2048,
1291 // C2[2]/eps^2, polynomial in eps2 of order 2
1292 35, 64, 384, 2048,
1293 // C2[3]/eps^3, polynomial in eps2 of order 2
1294 69, 120, 640, 6144,
1295 // C2[4]/eps^4, polynomial in eps2 of order 1
1296 7, 35, 512,
1297 // C2[5]/eps^5, polynomial in eps2 of order 1
1298 105, 504, 10240,
1299 // C2[6]/eps^6, polynomial in eps2 of order 0
1300 77, 2048,
1301 // C2[7]/eps^7, polynomial in eps2 of order 0
1302 429, 14336,
1303 };
1304#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1305 static const real coeff[] = {
1306 // C2[1]/eps^1, polynomial in eps2 of order 3
1307 41, 64, 128, 1024, 2048,
1308 // C2[2]/eps^2, polynomial in eps2 of order 3
1309 47, 70, 128, 768, 4096,
1310 // C2[3]/eps^3, polynomial in eps2 of order 2
1311 69, 120, 640, 6144,
1312 // C2[4]/eps^4, polynomial in eps2 of order 2
1313 133, 224, 1120, 16384,
1314 // C2[5]/eps^5, polynomial in eps2 of order 1
1315 105, 504, 10240,
1316 // C2[6]/eps^6, polynomial in eps2 of order 1
1317 33, 154, 4096,
1318 // C2[7]/eps^7, polynomial in eps2 of order 0
1319 429, 14336,
1320 // C2[8]/eps^8, polynomial in eps2 of order 0
1321 6435, 262144,
1322 };
1323#else
1324#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1325#endif
1326 static_assert(sizeof(coeff) / sizeof(real) ==
1327 (nC2_*nC2_ + 7*nC2_ - 2*(nC2_/2)) / 4,
1328 "Coefficient array size mismatch in C2f");
1329 real
1330 eps2 = Math::sq(eps),
1331 d = eps;
1332 int o = 0;
1333 for (int l = 1; l <= nC2_; ++l) { // l is index of C2[l]
1334 int m = (nC2_ - l) / 2; // order of polynomial in eps^2
1335 c[l] = d * Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1336 o += m + 2;
1337 d *= eps;
1338 }
1339 // Post condition: o == sizeof(coeff) / sizeof(real)
1340 }
1341
1342 // The scale factor A3 = mean value of (d/dsigma)I3
1343 void Geodesic::A3coeff() {
1344 // Generated by Maxima on 2015-05-05 18:08:13-04:00
1345#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1346 static const real coeff[] = {
1347 // A3, coeff of eps^2, polynomial in n of order 0
1348 -1, 4,
1349 // A3, coeff of eps^1, polynomial in n of order 1
1350 1, -1, 2,
1351 // A3, coeff of eps^0, polynomial in n of order 0
1352 1, 1,
1353 };
1354#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1355 static const real coeff[] = {
1356 // A3, coeff of eps^3, polynomial in n of order 0
1357 -1, 16,
1358 // A3, coeff of eps^2, polynomial in n of order 1
1359 -1, -2, 8,
1360 // A3, coeff of eps^1, polynomial in n of order 1
1361 1, -1, 2,
1362 // A3, coeff of eps^0, polynomial in n of order 0
1363 1, 1,
1364 };
1365#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1366 static const real coeff[] = {
1367 // A3, coeff of eps^4, polynomial in n of order 0
1368 -3, 64,
1369 // A3, coeff of eps^3, polynomial in n of order 1
1370 -3, -1, 16,
1371 // A3, coeff of eps^2, polynomial in n of order 2
1372 3, -1, -2, 8,
1373 // A3, coeff of eps^1, polynomial in n of order 1
1374 1, -1, 2,
1375 // A3, coeff of eps^0, polynomial in n of order 0
1376 1, 1,
1377 };
1378#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1379 static const real coeff[] = {
1380 // A3, coeff of eps^5, polynomial in n of order 0
1381 -3, 128,
1382 // A3, coeff of eps^4, polynomial in n of order 1
1383 -2, -3, 64,
1384 // A3, coeff of eps^3, polynomial in n of order 2
1385 -1, -3, -1, 16,
1386 // A3, coeff of eps^2, polynomial in n of order 2
1387 3, -1, -2, 8,
1388 // A3, coeff of eps^1, polynomial in n of order 1
1389 1, -1, 2,
1390 // A3, coeff of eps^0, polynomial in n of order 0
1391 1, 1,
1392 };
1393#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1394 static const real coeff[] = {
1395 // A3, coeff of eps^6, polynomial in n of order 0
1396 -5, 256,
1397 // A3, coeff of eps^5, polynomial in n of order 1
1398 -5, -3, 128,
1399 // A3, coeff of eps^4, polynomial in n of order 2
1400 -10, -2, -3, 64,
1401 // A3, coeff of eps^3, polynomial in n of order 3
1402 5, -1, -3, -1, 16,
1403 // A3, coeff of eps^2, polynomial in n of order 2
1404 3, -1, -2, 8,
1405 // A3, coeff of eps^1, polynomial in n of order 1
1406 1, -1, 2,
1407 // A3, coeff of eps^0, polynomial in n of order 0
1408 1, 1,
1409 };
1410#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1411 static const real coeff[] = {
1412 // A3, coeff of eps^7, polynomial in n of order 0
1413 -25, 2048,
1414 // A3, coeff of eps^6, polynomial in n of order 1
1415 -15, -20, 1024,
1416 // A3, coeff of eps^5, polynomial in n of order 2
1417 -5, -10, -6, 256,
1418 // A3, coeff of eps^4, polynomial in n of order 3
1419 -5, -20, -4, -6, 128,
1420 // A3, coeff of eps^3, polynomial in n of order 3
1421 5, -1, -3, -1, 16,
1422 // A3, coeff of eps^2, polynomial in n of order 2
1423 3, -1, -2, 8,
1424 // A3, coeff of eps^1, polynomial in n of order 1
1425 1, -1, 2,
1426 // A3, coeff of eps^0, polynomial in n of order 0
1427 1, 1,
1428 };
1429#else
1430#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1431#endif
1432 static_assert(sizeof(coeff) / sizeof(real) ==
1433 (nA3_*nA3_ + 7*nA3_ - 2*(nA3_/2)) / 4,
1434 "Coefficient array size mismatch in A3f");
1435 int o = 0, k = 0;
1436 for (int j = nA3_ - 1; j >= 0; --j) { // coeff of eps^j
1437 int m = min(nA3_ - j - 1, j); // order of polynomial in n
1438 _aA3x[k++] = Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1439 o += m + 2;
1440 }
1441 // Post condition: o == sizeof(coeff) / sizeof(real) && k == nA3x_
1442 }
1443
1444 // The coefficients C3[l] in the Fourier expansion of B3
1445 void Geodesic::C3coeff() {
1446 // Generated by Maxima on 2015-05-05 18:08:13-04:00
1447#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1448 static const real coeff[] = {
1449 // C3[1], coeff of eps^2, polynomial in n of order 0
1450 1, 8,
1451 // C3[1], coeff of eps^1, polynomial in n of order 1
1452 -1, 1, 4,
1453 // C3[2], coeff of eps^2, polynomial in n of order 0
1454 1, 16,
1455 };
1456#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1457 static const real coeff[] = {
1458 // C3[1], coeff of eps^3, polynomial in n of order 0
1459 3, 64,
1460 // C3[1], coeff of eps^2, polynomial in n of order 1
1461 // This is a case where a leading 0 term has been inserted to maintain the
1462 // pattern in the orders of the polynomials.
1463 0, 1, 8,
1464 // C3[1], coeff of eps^1, polynomial in n of order 1
1465 -1, 1, 4,
1466 // C3[2], coeff of eps^3, polynomial in n of order 0
1467 3, 64,
1468 // C3[2], coeff of eps^2, polynomial in n of order 1
1469 -3, 2, 32,
1470 // C3[3], coeff of eps^3, polynomial in n of order 0
1471 5, 192,
1472 };
1473#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1474 static const real coeff[] = {
1475 // C3[1], coeff of eps^4, polynomial in n of order 0
1476 5, 128,
1477 // C3[1], coeff of eps^3, polynomial in n of order 1
1478 3, 3, 64,
1479 // C3[1], coeff of eps^2, polynomial in n of order 2
1480 -1, 0, 1, 8,
1481 // C3[1], coeff of eps^1, polynomial in n of order 1
1482 -1, 1, 4,
1483 // C3[2], coeff of eps^4, polynomial in n of order 0
1484 3, 128,
1485 // C3[2], coeff of eps^3, polynomial in n of order 1
1486 -2, 3, 64,
1487 // C3[2], coeff of eps^2, polynomial in n of order 2
1488 1, -3, 2, 32,
1489 // C3[3], coeff of eps^4, polynomial in n of order 0
1490 3, 128,
1491 // C3[3], coeff of eps^3, polynomial in n of order 1
1492 -9, 5, 192,
1493 // C3[4], coeff of eps^4, polynomial in n of order 0
1494 7, 512,
1495 };
1496#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1497 static const real coeff[] = {
1498 // C3[1], coeff of eps^5, polynomial in n of order 0
1499 3, 128,
1500 // C3[1], coeff of eps^4, polynomial in n of order 1
1501 2, 5, 128,
1502 // C3[1], coeff of eps^3, polynomial in n of order 2
1503 -1, 3, 3, 64,
1504 // C3[1], coeff of eps^2, polynomial in n of order 2
1505 -1, 0, 1, 8,
1506 // C3[1], coeff of eps^1, polynomial in n of order 1
1507 -1, 1, 4,
1508 // C3[2], coeff of eps^5, polynomial in n of order 0
1509 5, 256,
1510 // C3[2], coeff of eps^4, polynomial in n of order 1
1511 1, 3, 128,
1512 // C3[2], coeff of eps^3, polynomial in n of order 2
1513 -3, -2, 3, 64,
1514 // C3[2], coeff of eps^2, polynomial in n of order 2
1515 1, -3, 2, 32,
1516 // C3[3], coeff of eps^5, polynomial in n of order 0
1517 7, 512,
1518 // C3[3], coeff of eps^4, polynomial in n of order 1
1519 -10, 9, 384,
1520 // C3[3], coeff of eps^3, polynomial in n of order 2
1521 5, -9, 5, 192,
1522 // C3[4], coeff of eps^5, polynomial in n of order 0
1523 7, 512,
1524 // C3[4], coeff of eps^4, polynomial in n of order 1
1525 -14, 7, 512,
1526 // C3[5], coeff of eps^5, polynomial in n of order 0
1527 21, 2560,
1528 };
1529#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1530 static const real coeff[] = {
1531 // C3[1], coeff of eps^6, polynomial in n of order 0
1532 21, 1024,
1533 // C3[1], coeff of eps^5, polynomial in n of order 1
1534 11, 12, 512,
1535 // C3[1], coeff of eps^4, polynomial in n of order 2
1536 2, 2, 5, 128,
1537 // C3[1], coeff of eps^3, polynomial in n of order 3
1538 -5, -1, 3, 3, 64,
1539 // C3[1], coeff of eps^2, polynomial in n of order 2
1540 -1, 0, 1, 8,
1541 // C3[1], coeff of eps^1, polynomial in n of order 1
1542 -1, 1, 4,
1543 // C3[2], coeff of eps^6, polynomial in n of order 0
1544 27, 2048,
1545 // C3[2], coeff of eps^5, polynomial in n of order 1
1546 1, 5, 256,
1547 // C3[2], coeff of eps^4, polynomial in n of order 2
1548 -9, 2, 6, 256,
1549 // C3[2], coeff of eps^3, polynomial in n of order 3
1550 2, -3, -2, 3, 64,
1551 // C3[2], coeff of eps^2, polynomial in n of order 2
1552 1, -3, 2, 32,
1553 // C3[3], coeff of eps^6, polynomial in n of order 0
1554 3, 256,
1555 // C3[3], coeff of eps^5, polynomial in n of order 1
1556 -4, 21, 1536,
1557 // C3[3], coeff of eps^4, polynomial in n of order 2
1558 -6, -10, 9, 384,
1559 // C3[3], coeff of eps^3, polynomial in n of order 3
1560 -1, 5, -9, 5, 192,
1561 // C3[4], coeff of eps^6, polynomial in n of order 0
1562 9, 1024,
1563 // C3[4], coeff of eps^5, polynomial in n of order 1
1564 -10, 7, 512,
1565 // C3[4], coeff of eps^4, polynomial in n of order 2
1566 10, -14, 7, 512,
1567 // C3[5], coeff of eps^6, polynomial in n of order 0
1568 9, 1024,
1569 // C3[5], coeff of eps^5, polynomial in n of order 1
1570 -45, 21, 2560,
1571 // C3[6], coeff of eps^6, polynomial in n of order 0
1572 11, 2048,
1573 };
1574#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1575 static const real coeff[] = {
1576 // C3[1], coeff of eps^7, polynomial in n of order 0
1577 243, 16384,
1578 // C3[1], coeff of eps^6, polynomial in n of order 1
1579 10, 21, 1024,
1580 // C3[1], coeff of eps^5, polynomial in n of order 2
1581 3, 11, 12, 512,
1582 // C3[1], coeff of eps^4, polynomial in n of order 3
1583 -2, 2, 2, 5, 128,
1584 // C3[1], coeff of eps^3, polynomial in n of order 3
1585 -5, -1, 3, 3, 64,
1586 // C3[1], coeff of eps^2, polynomial in n of order 2
1587 -1, 0, 1, 8,
1588 // C3[1], coeff of eps^1, polynomial in n of order 1
1589 -1, 1, 4,
1590 // C3[2], coeff of eps^7, polynomial in n of order 0
1591 187, 16384,
1592 // C3[2], coeff of eps^6, polynomial in n of order 1
1593 69, 108, 8192,
1594 // C3[2], coeff of eps^5, polynomial in n of order 2
1595 -2, 1, 5, 256,
1596 // C3[2], coeff of eps^4, polynomial in n of order 3
1597 -6, -9, 2, 6, 256,
1598 // C3[2], coeff of eps^3, polynomial in n of order 3
1599 2, -3, -2, 3, 64,
1600 // C3[2], coeff of eps^2, polynomial in n of order 2
1601 1, -3, 2, 32,
1602 // C3[3], coeff of eps^7, polynomial in n of order 0
1603 139, 16384,
1604 // C3[3], coeff of eps^6, polynomial in n of order 1
1605 -1, 12, 1024,
1606 // C3[3], coeff of eps^5, polynomial in n of order 2
1607 -77, -8, 42, 3072,
1608 // C3[3], coeff of eps^4, polynomial in n of order 3
1609 10, -6, -10, 9, 384,
1610 // C3[3], coeff of eps^3, polynomial in n of order 3
1611 -1, 5, -9, 5, 192,
1612 // C3[4], coeff of eps^7, polynomial in n of order 0
1613 127, 16384,
1614 // C3[4], coeff of eps^6, polynomial in n of order 1
1615 -43, 72, 8192,
1616 // C3[4], coeff of eps^5, polynomial in n of order 2
1617 -7, -40, 28, 2048,
1618 // C3[4], coeff of eps^4, polynomial in n of order 3
1619 -7, 20, -28, 14, 1024,
1620 // C3[5], coeff of eps^7, polynomial in n of order 0
1621 99, 16384,
1622 // C3[5], coeff of eps^6, polynomial in n of order 1
1623 -15, 9, 1024,
1624 // C3[5], coeff of eps^5, polynomial in n of order 2
1625 75, -90, 42, 5120,
1626 // C3[6], coeff of eps^7, polynomial in n of order 0
1627 99, 16384,
1628 // C3[6], coeff of eps^6, polynomial in n of order 1
1629 -99, 44, 8192,
1630 // C3[7], coeff of eps^7, polynomial in n of order 0
1631 429, 114688,
1632 };
1633#else
1634#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1635#endif
1636 static_assert(sizeof(coeff) / sizeof(real) ==
1637 ((nC3_-1)*(nC3_*nC3_ + 7*nC3_ - 2*(nC3_/2)))/8,
1638 "Coefficient array size mismatch in C3coeff");
1639 int o = 0, k = 0;
1640 for (int l = 1; l < nC3_; ++l) { // l is index of C3[l]
1641 for (int j = nC3_ - 1; j >= l; --j) { // coeff of eps^j
1642 int m = min(nC3_ - j - 1, j); // order of polynomial in n
1643 _cC3x[k++] = Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1644 o += m + 2;
1645 }
1646 }
1647 // Post condition: o == sizeof(coeff) / sizeof(real) && k == nC3x_
1648 }
1649
1650 void Geodesic::C4coeff() {
1651 // Generated by Maxima on 2015-05-05 18:08:13-04:00
1652#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1653 static const real coeff[] = {
1654 // C4[0], coeff of eps^2, polynomial in n of order 0
1655 -2, 105,
1656 // C4[0], coeff of eps^1, polynomial in n of order 1
1657 16, -7, 35,
1658 // C4[0], coeff of eps^0, polynomial in n of order 2
1659 8, -28, 70, 105,
1660 // C4[1], coeff of eps^2, polynomial in n of order 0
1661 -2, 105,
1662 // C4[1], coeff of eps^1, polynomial in n of order 1
1663 -16, 7, 315,
1664 // C4[2], coeff of eps^2, polynomial in n of order 0
1665 4, 525,
1666 };
1667#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1668 static const real coeff[] = {
1669 // C4[0], coeff of eps^3, polynomial in n of order 0
1670 11, 315,
1671 // C4[0], coeff of eps^2, polynomial in n of order 1
1672 -32, -6, 315,
1673 // C4[0], coeff of eps^1, polynomial in n of order 2
1674 -32, 48, -21, 105,
1675 // C4[0], coeff of eps^0, polynomial in n of order 3
1676 4, 24, -84, 210, 315,
1677 // C4[1], coeff of eps^3, polynomial in n of order 0
1678 -1, 105,
1679 // C4[1], coeff of eps^2, polynomial in n of order 1
1680 64, -18, 945,
1681 // C4[1], coeff of eps^1, polynomial in n of order 2
1682 32, -48, 21, 945,
1683 // C4[2], coeff of eps^3, polynomial in n of order 0
1684 -8, 1575,
1685 // C4[2], coeff of eps^2, polynomial in n of order 1
1686 -32, 12, 1575,
1687 // C4[3], coeff of eps^3, polynomial in n of order 0
1688 8, 2205,
1689 };
1690#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1691 static const real coeff[] = {
1692 // C4[0], coeff of eps^4, polynomial in n of order 0
1693 4, 1155,
1694 // C4[0], coeff of eps^3, polynomial in n of order 1
1695 -368, 121, 3465,
1696 // C4[0], coeff of eps^2, polynomial in n of order 2
1697 1088, -352, -66, 3465,
1698 // C4[0], coeff of eps^1, polynomial in n of order 3
1699 48, -352, 528, -231, 1155,
1700 // C4[0], coeff of eps^0, polynomial in n of order 4
1701 16, 44, 264, -924, 2310, 3465,
1702 // C4[1], coeff of eps^4, polynomial in n of order 0
1703 4, 1155,
1704 // C4[1], coeff of eps^3, polynomial in n of order 1
1705 80, -99, 10395,
1706 // C4[1], coeff of eps^2, polynomial in n of order 2
1707 -896, 704, -198, 10395,
1708 // C4[1], coeff of eps^1, polynomial in n of order 3
1709 -48, 352, -528, 231, 10395,
1710 // C4[2], coeff of eps^4, polynomial in n of order 0
1711 -8, 1925,
1712 // C4[2], coeff of eps^3, polynomial in n of order 1
1713 384, -88, 17325,
1714 // C4[2], coeff of eps^2, polynomial in n of order 2
1715 320, -352, 132, 17325,
1716 // C4[3], coeff of eps^4, polynomial in n of order 0
1717 -16, 8085,
1718 // C4[3], coeff of eps^3, polynomial in n of order 1
1719 -256, 88, 24255,
1720 // C4[4], coeff of eps^4, polynomial in n of order 0
1721 64, 31185,
1722 };
1723#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1724 static const real coeff[] = {
1725 // C4[0], coeff of eps^5, polynomial in n of order 0
1726 97, 15015,
1727 // C4[0], coeff of eps^4, polynomial in n of order 1
1728 1088, 156, 45045,
1729 // C4[0], coeff of eps^3, polynomial in n of order 2
1730 -224, -4784, 1573, 45045,
1731 // C4[0], coeff of eps^2, polynomial in n of order 3
1732 -10656, 14144, -4576, -858, 45045,
1733 // C4[0], coeff of eps^1, polynomial in n of order 4
1734 64, 624, -4576, 6864, -3003, 15015,
1735 // C4[0], coeff of eps^0, polynomial in n of order 5
1736 100, 208, 572, 3432, -12012, 30030, 45045,
1737 // C4[1], coeff of eps^5, polynomial in n of order 0
1738 1, 9009,
1739 // C4[1], coeff of eps^4, polynomial in n of order 1
1740 -2944, 468, 135135,
1741 // C4[1], coeff of eps^3, polynomial in n of order 2
1742 5792, 1040, -1287, 135135,
1743 // C4[1], coeff of eps^2, polynomial in n of order 3
1744 5952, -11648, 9152, -2574, 135135,
1745 // C4[1], coeff of eps^1, polynomial in n of order 4
1746 -64, -624, 4576, -6864, 3003, 135135,
1747 // C4[2], coeff of eps^5, polynomial in n of order 0
1748 8, 10725,
1749 // C4[2], coeff of eps^4, polynomial in n of order 1
1750 1856, -936, 225225,
1751 // C4[2], coeff of eps^3, polynomial in n of order 2
1752 -8448, 4992, -1144, 225225,
1753 // C4[2], coeff of eps^2, polynomial in n of order 3
1754 -1440, 4160, -4576, 1716, 225225,
1755 // C4[3], coeff of eps^5, polynomial in n of order 0
1756 -136, 63063,
1757 // C4[3], coeff of eps^4, polynomial in n of order 1
1758 1024, -208, 105105,
1759 // C4[3], coeff of eps^3, polynomial in n of order 2
1760 3584, -3328, 1144, 315315,
1761 // C4[4], coeff of eps^5, polynomial in n of order 0
1762 -128, 135135,
1763 // C4[4], coeff of eps^4, polynomial in n of order 1
1764 -2560, 832, 405405,
1765 // C4[5], coeff of eps^5, polynomial in n of order 0
1766 128, 99099,
1767 };
1768#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1769 static const real coeff[] = {
1770 // C4[0], coeff of eps^6, polynomial in n of order 0
1771 10, 9009,
1772 // C4[0], coeff of eps^5, polynomial in n of order 1
1773 -464, 291, 45045,
1774 // C4[0], coeff of eps^4, polynomial in n of order 2
1775 -4480, 1088, 156, 45045,
1776 // C4[0], coeff of eps^3, polynomial in n of order 3
1777 10736, -224, -4784, 1573, 45045,
1778 // C4[0], coeff of eps^2, polynomial in n of order 4
1779 1664, -10656, 14144, -4576, -858, 45045,
1780 // C4[0], coeff of eps^1, polynomial in n of order 5
1781 16, 64, 624, -4576, 6864, -3003, 15015,
1782 // C4[0], coeff of eps^0, polynomial in n of order 6
1783 56, 100, 208, 572, 3432, -12012, 30030, 45045,
1784 // C4[1], coeff of eps^6, polynomial in n of order 0
1785 10, 9009,
1786 // C4[1], coeff of eps^5, polynomial in n of order 1
1787 112, 15, 135135,
1788 // C4[1], coeff of eps^4, polynomial in n of order 2
1789 3840, -2944, 468, 135135,
1790 // C4[1], coeff of eps^3, polynomial in n of order 3
1791 -10704, 5792, 1040, -1287, 135135,
1792 // C4[1], coeff of eps^2, polynomial in n of order 4
1793 -768, 5952, -11648, 9152, -2574, 135135,
1794 // C4[1], coeff of eps^1, polynomial in n of order 5
1795 -16, -64, -624, 4576, -6864, 3003, 135135,
1796 // C4[2], coeff of eps^6, polynomial in n of order 0
1797 -4, 25025,
1798 // C4[2], coeff of eps^5, polynomial in n of order 1
1799 -1664, 168, 225225,
1800 // C4[2], coeff of eps^4, polynomial in n of order 2
1801 1664, 1856, -936, 225225,
1802 // C4[2], coeff of eps^3, polynomial in n of order 3
1803 6784, -8448, 4992, -1144, 225225,
1804 // C4[2], coeff of eps^2, polynomial in n of order 4
1805 128, -1440, 4160, -4576, 1716, 225225,
1806 // C4[3], coeff of eps^6, polynomial in n of order 0
1807 64, 315315,
1808 // C4[3], coeff of eps^5, polynomial in n of order 1
1809 1792, -680, 315315,
1810 // C4[3], coeff of eps^4, polynomial in n of order 2
1811 -2048, 1024, -208, 105105,
1812 // C4[3], coeff of eps^3, polynomial in n of order 3
1813 -1792, 3584, -3328, 1144, 315315,
1814 // C4[4], coeff of eps^6, polynomial in n of order 0
1815 -512, 405405,
1816 // C4[4], coeff of eps^5, polynomial in n of order 1
1817 2048, -384, 405405,
1818 // C4[4], coeff of eps^4, polynomial in n of order 2
1819 3072, -2560, 832, 405405,
1820 // C4[5], coeff of eps^6, polynomial in n of order 0
1821 -256, 495495,
1822 // C4[5], coeff of eps^5, polynomial in n of order 1
1823 -2048, 640, 495495,
1824 // C4[6], coeff of eps^6, polynomial in n of order 0
1825 512, 585585,
1826 };
1827#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1828 static const real coeff[] = {
1829 // C4[0], coeff of eps^7, polynomial in n of order 0
1830 193, 85085,
1831 // C4[0], coeff of eps^6, polynomial in n of order 1
1832 4192, 850, 765765,
1833 // C4[0], coeff of eps^5, polynomial in n of order 2
1834 20960, -7888, 4947, 765765,
1835 // C4[0], coeff of eps^4, polynomial in n of order 3
1836 12480, -76160, 18496, 2652, 765765,
1837 // C4[0], coeff of eps^3, polynomial in n of order 4
1838 -154048, 182512, -3808, -81328, 26741, 765765,
1839 // C4[0], coeff of eps^2, polynomial in n of order 5
1840 3232, 28288, -181152, 240448, -77792, -14586, 765765,
1841 // C4[0], coeff of eps^1, polynomial in n of order 6
1842 96, 272, 1088, 10608, -77792, 116688, -51051, 255255,
1843 // C4[0], coeff of eps^0, polynomial in n of order 7
1844 588, 952, 1700, 3536, 9724, 58344, -204204, 510510, 765765,
1845 // C4[1], coeff of eps^7, polynomial in n of order 0
1846 349, 2297295,
1847 // C4[1], coeff of eps^6, polynomial in n of order 1
1848 -1472, 510, 459459,
1849 // C4[1], coeff of eps^5, polynomial in n of order 2
1850 -39840, 1904, 255, 2297295,
1851 // C4[1], coeff of eps^4, polynomial in n of order 3
1852 52608, 65280, -50048, 7956, 2297295,
1853 // C4[1], coeff of eps^3, polynomial in n of order 4
1854 103744, -181968, 98464, 17680, -21879, 2297295,
1855 // C4[1], coeff of eps^2, polynomial in n of order 5
1856 -1344, -13056, 101184, -198016, 155584, -43758, 2297295,
1857 // C4[1], coeff of eps^1, polynomial in n of order 6
1858 -96, -272, -1088, -10608, 77792, -116688, 51051, 2297295,
1859 // C4[2], coeff of eps^7, polynomial in n of order 0
1860 464, 1276275,
1861 // C4[2], coeff of eps^6, polynomial in n of order 1
1862 -928, -612, 3828825,
1863 // C4[2], coeff of eps^5, polynomial in n of order 2
1864 64256, -28288, 2856, 3828825,
1865 // C4[2], coeff of eps^4, polynomial in n of order 3
1866 -126528, 28288, 31552, -15912, 3828825,
1867 // C4[2], coeff of eps^3, polynomial in n of order 4
1868 -41472, 115328, -143616, 84864, -19448, 3828825,
1869 // C4[2], coeff of eps^2, polynomial in n of order 5
1870 160, 2176, -24480, 70720, -77792, 29172, 3828825,
1871 // C4[3], coeff of eps^7, polynomial in n of order 0
1872 -16, 97461,
1873 // C4[3], coeff of eps^6, polynomial in n of order 1
1874 -16384, 1088, 5360355,
1875 // C4[3], coeff of eps^5, polynomial in n of order 2
1876 -2560, 30464, -11560, 5360355,
1877 // C4[3], coeff of eps^4, polynomial in n of order 3
1878 35840, -34816, 17408, -3536, 1786785,
1879 // C4[3], coeff of eps^3, polynomial in n of order 4
1880 7168, -30464, 60928, -56576, 19448, 5360355,
1881 // C4[4], coeff of eps^7, polynomial in n of order 0
1882 128, 2297295,
1883 // C4[4], coeff of eps^6, polynomial in n of order 1
1884 26624, -8704, 6891885,
1885 // C4[4], coeff of eps^5, polynomial in n of order 2
1886 -77824, 34816, -6528, 6891885,
1887 // C4[4], coeff of eps^4, polynomial in n of order 3
1888 -32256, 52224, -43520, 14144, 6891885,
1889 // C4[5], coeff of eps^7, polynomial in n of order 0
1890 -6784, 8423415,
1891 // C4[5], coeff of eps^6, polynomial in n of order 1
1892 24576, -4352, 8423415,
1893 // C4[5], coeff of eps^5, polynomial in n of order 2
1894 45056, -34816, 10880, 8423415,
1895 // C4[6], coeff of eps^7, polynomial in n of order 0
1896 -1024, 3318315,
1897 // C4[6], coeff of eps^6, polynomial in n of order 1
1898 -28672, 8704, 9954945,
1899 // C4[7], coeff of eps^7, polynomial in n of order 0
1900 1024, 1640925,
1901 };
1902#else
1903#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1904#endif
1905 static_assert(sizeof(coeff) / sizeof(real) ==
1906 (nC4_ * (nC4_ + 1) * (nC4_ + 5)) / 6,
1907 "Coefficient array size mismatch in C4coeff");
1908 int o = 0, k = 0;
1909 for (int l = 0; l < nC4_; ++l) { // l is index of C4[l]
1910 for (int j = nC4_ - 1; j >= l; --j) { // coeff of eps^j
1911 int m = nC4_ - j - 1; // order of polynomial in n
1912 _cC4x[k++] = Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1913 o += m + 2;
1914 }
1915 }
1916 // Post condition: o == sizeof(coeff) / sizeof(real) && k == nC4x_
1917 }
1918
1919} // namespace GeographicLib
real
GeographicLib::Math::real real
Definition: GeodSolve.cpp:29
GeodesicLine.hpp
Header for GeographicLib::GeodesicLine class.
Geodesic.hpp
Header for GeographicLib::Geodesic class.
GeographicLib::Constants::WGS84_f
static T WGS84_f()
Definition: Constants.hpp:141
GeographicLib::Constants::WGS84_a
static T WGS84_a()
Definition: Constants.hpp:135
GeographicLib::GeodesicExact
Exact geodesic calculations.
Definition: GeodesicExact.hpp:84
GeographicLib::GeodesicExact::GenDirect
Math::real GenDirect(real lat1, real lon1, real azi1, bool arcmode, real s12_a12, unsigned outmask, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const
Definition: GeodesicExact.cpp:403
GeographicLib::GeodesicLine
A geodesic line.
Definition: GeodesicLine.hpp:74
GeographicLib::Geodesic
Geodesic calculations
Definition: Geodesic.hpp:175
GeographicLib::Geodesic::InverseLine
GeodesicLine InverseLine(real lat1, real lon1, real lat2, real lon2, unsigned caps=ALL) const
Definition: Geodesic.cpp:533
GeographicLib::Geodesic::WGS84
static const Geodesic & WGS84()
Definition: Geodesic.cpp:95
GeographicLib::Geodesic::ArcDirectLine
GeodesicLine ArcDirectLine(real lat1, real lon1, real azi1, real a12, unsigned caps=ALL) const
Definition: Geodesic.cpp:164
GeographicLib::Geodesic::Line
GeodesicLine Line(real lat1, real lon1, real azi1, unsigned caps=ALL) const
Definition: Geodesic.cpp:124
GeographicLib::Geodesic::GenDirectLine
GeodesicLine GenDirectLine(real lat1, real lon1, real azi1, bool arcmode, real s12_a12, unsigned caps=ALL) const
Definition: Geodesic.cpp:146
GeographicLib::Geodesic::DISTANCE
@ DISTANCE
Definition: Geodesic.hpp:296
GeographicLib::Geodesic::REDUCEDLENGTH
@ REDUCEDLENGTH
Definition: Geodesic.hpp:313
GeographicLib::Geodesic::AREA
@ AREA
Definition: Geodesic.hpp:323
GeographicLib::Geodesic::AZIMUTH
@ AZIMUTH
Definition: Geodesic.hpp:291
GeographicLib::Geodesic::NONE
@ NONE
Definition: Geodesic.hpp:273
GeographicLib::Geodesic::DISTANCE_IN
@ DISTANCE_IN
Definition: Geodesic.hpp:308
GeographicLib::Geodesic::GEODESICSCALE
@ GEODESICSCALE
Definition: Geodesic.hpp:318
GeographicLib::Geodesic::GeodesicLine
friend class GeodesicLine
Definition: Geodesic.hpp:178
GeographicLib::Geodesic::GenDirect
Math::real GenDirect(real lat1, real lon1, real azi1, bool arcmode, real s12_a12, unsigned outmask, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const
Definition: Geodesic.cpp:129
GeographicLib::Geodesic::DirectLine
GeodesicLine DirectLine(real lat1, real lon1, real azi1, real s12, unsigned caps=ALL) const
Definition: Geodesic.cpp:159
GeographicLib::Geodesic::Geodesic
Geodesic(real a, real f, bool exact=false)
Definition: Geodesic.cpp:42
GeographicLib::GeographicErr
Exception handling for GeographicLib.
Definition: Constants.hpp:316
GeographicLib::Math
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:77
GeographicLib::Math::degree
static T degree()
Definition: Math.hpp:193
GeographicLib::Math::LatFix
static T LatFix(T x)
Definition: Math.hpp:293
GeographicLib::Math::sincosd
static void sincosd(T x, T &sinx, T &cosx)
Definition: Math.cpp:106
GeographicLib::Math::atan2d
static T atan2d(T y, T x)
Definition: Math.cpp:183
GeographicLib::Math::norm
static void norm(T &x, T &y)
Definition: Math.hpp:215
GeographicLib::Math::AngRound
static T AngRound(T x)
Definition: Math.cpp:97
GeographicLib::Math::sq
static T sq(T x)
Definition: Math.hpp:205
GeographicLib::Math::AngNormalize
static T AngNormalize(T x)
Definition: Math.cpp:71
GeographicLib::Math::sincosde
static void sincosde(T x, T t, T &sinx, T &cosx)
Definition: Math.cpp:126
GeographicLib::Math::pi
static T pi()
Definition: Math.hpp:183
GeographicLib::Math::polyval
static T polyval(int N, const T p[], T x)
Definition: Math.hpp:264
GeographicLib::Math::AngDiff
static T AngDiff(T x, T y, T &e)
Definition: Math.cpp:82
GeographicLib::Math::real
double real
Definition: Math.hpp:100
GeographicLib::Math::hd
@ hd
degrees per half turn
Definition: Math.hpp:141
GeographicLib::Math::qd
@ qd
degrees per quarter turn
Definition: Math.hpp:138
GeographicLib
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
std
Definition: NearestNeighbor.hpp:812
std::swap
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
Definition: NearestNeighbor.hpp:825