35 # pragma warning (disable: 4701 4127)
43 : maxit2_(maxit1_ +
Math::digits() + 10)
47 , tiny_(sqrt(numeric_limits<real>::min()))
48 , tol0_(numeric_limits<real>::epsilon())
54 , tolb_(tol0_ * tol2_)
55 , xthresh_(1000 * tol2_)
60 , _ep2(_e2 /
Math::sq(_f1))
65 Math::eatanhe(real(1), (_f < 0 ? -1 : 1) * sqrt(abs(_e2))) / _e2))
77 , _etol2(real(0.1) * tol2_ /
78 sqrt( max(real(0.001), abs(_f)) * min(real(1), 1 - _f/2) / 2 ))
80 if (!(isfinite(_a) && _a > 0))
82 if (!(isfinite(_b) && _b > 0))
96 const real c[],
int n) {
104 ar = 2 * (cosx - sinx) * (cosx + sinx),
105 y0 = n & 1 ? *--c : 0, y1 = 0;
110 y1 = ar * y0 - y1 + *--c;
111 y0 = ar * y1 - y0 + *--c;
114 ? 2 * sinx * cosx * y0
119 unsigned caps)
const {
124 bool arcmode, real s12_a12,
unsigned outmask,
125 real& lat2, real& lon2, real& azi2,
126 real& s12, real& m12, real& M12, real& M21,
132 GenPosition(arcmode, s12_a12, outmask,
133 lat2, lon2, azi2, s12, m12, M12, M21, S12);
137 bool arcmode, real s12_a12,
138 unsigned caps)
const {
145 return GeodesicLine(*
this, lat1, lon1, azi1, salp1, calp1,
146 caps, arcmode, s12_a12);
150 unsigned caps)
const {
155 real a12,
unsigned caps)
const {
160 unsigned outmask,
real& s12,
170 int lonsign = lon12 >= 0 ? 1 : -1;
188 int swapp = abs(lat1) < abs(lat2) ? -1 : 1;
194 int latsign = lat1 < 0 ? 1 : -1;
209 real sbet1, cbet1, sbet2, cbet2, s12x, m12x;
214 Math::norm(sbet1, cbet1); cbet1 = max(tiny_, cbet1);
218 Math::norm(sbet2, cbet2); cbet2 = max(tiny_, cbet2);
228 if (cbet1 < -sbet1) {
230 sbet2 = sbet2 < 0 ? sbet1 : -sbet1;
232 if (abs(sbet2) == -sbet1)
237 dn1 = sqrt(1 + _ep2 *
Math::sq(sbet1)),
238 dn2 = sqrt(1 + _ep2 *
Math::sq(sbet2));
244 bool meridian = lat1 == -90 || slam12 == 0;
251 calp1 = clam12; salp1 = slam12;
252 calp2 = 1; salp2 = 0;
256 ssig1 = sbet1, csig1 = calp1 * cbet1,
257 ssig2 = sbet2, csig2 = calp2 * cbet2;
260 sig12 = atan2(max(
real(0), csig1 * ssig2 - ssig1 * csig2),
261 csig1 * csig2 + ssig1 * ssig2);
264 Lengths(_n, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2,
266 s12x, m12x, dummy, M12, M21, Ca);
280 if (sig12 < 1 || m12x >= 0) {
282 if (sig12 < 3 * tiny_ ||
284 (sig12 < tol0_ && (s12x < 0 || m12x < 0)))
285 sig12 = m12x = s12x = 0;
295 real omg12 = 0, somg12 = 2, comg12 = 0;
298 (_f <= 0 || lon12s >= _f * 180)) {
301 calp1 = calp2 = 0; salp1 = salp2 = 1;
303 sig12 = omg12 = lam12 / _f1;
304 m12x = _b * sin(sig12);
306 M12 = M21 = cos(sig12);
309 }
else if (!meridian) {
316 sig12 = InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2,
317 lam12, slam12, clam12,
318 salp1, calp1, salp2, calp2, dnm,
323 s12x = sig12 * _b * dnm;
324 m12x =
Math::sq(dnm) * _b * sin(sig12 / dnm);
326 M12 = M21 = cos(sig12 / dnm);
328 omg12 = lam12 / (_f1 * dnm);
344 real ssig1 = 0, csig1 = 0, ssig2 = 0, csig2 = 0, eps = 0, domg12 = 0;
347 real salp1a = tiny_, calp1a = 1, salp1b = tiny_, calp1b = -1;
348 for (
bool tripn =
false, tripb =
false;
354 real v = Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1,
356 salp2, calp2, sig12, ssig1, csig1, ssig2, csig2,
357 eps, domg12, numit < maxit1_, dv, Ca);
359 if (tripb || !(abs(v) >= (tripn ? 8 : 1) * tol0_))
break;
361 if (v > 0 && (numit > maxit1_ || calp1/salp1 > calp1b/salp1b))
362 { salp1b = salp1; calp1b = calp1; }
363 else if (v < 0 && (numit > maxit1_ || calp1/salp1 < calp1a/salp1a))
364 { salp1a = salp1; calp1a = calp1; }
365 if (numit < maxit1_ && dv > 0) {
369 sdalp1 = sin(dalp1), cdalp1 = cos(dalp1),
370 nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
371 if (nsalp1 > 0 && abs(dalp1) <
Math::pi()) {
372 calp1 = calp1 * cdalp1 - salp1 * sdalp1;
378 tripn = abs(v) <= 16 * tol0_;
390 salp1 = (salp1a + salp1b)/2;
391 calp1 = (calp1a + calp1b)/2;
394 tripb = (abs(salp1a - salp1) + (calp1a - calp1) < tolb_ ||
395 abs(salp1 - salp1b) + (calp1 - calp1b) < tolb_);
401 unsigned lengthmask = outmask |
403 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
404 cbet1, cbet2, lengthmask, s12x, m12x, dummy, M12, M21, Ca);
409 if (outmask &
AREA) {
411 real sdomg12 = sin(domg12), cdomg12 = cos(domg12);
412 somg12 = slam12 * cdomg12 - clam12 * sdomg12;
413 comg12 = clam12 * cdomg12 + slam12 * sdomg12;
424 if (outmask &
AREA) {
427 salp0 = salp1 * cbet1,
428 calp0 = hypot(calp1, salp1 * sbet1);
430 if (calp0 != 0 && salp0 != 0) {
433 ssig1 = sbet1, csig1 = calp1 * cbet1,
434 ssig2 = sbet2, csig2 = calp2 * cbet2,
436 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2),
438 A4 =
Math::sq(_a) * calp0 * salp0 * _e2;
443 B41 = SinCosSeries(
false, ssig1, csig1, Ca, nC4_),
444 B42 = SinCosSeries(
false, ssig2, csig2, Ca, nC4_);
445 S12 = A4 * (B42 - B41);
450 if (!meridian && somg12 > 1) {
451 somg12 = sin(omg12); comg12 = cos(omg12);
456 comg12 > -
real(0.7071) &&
457 sbet2 - sbet1 <
real(1.75)) {
461 real domg12 = 1 + comg12, dbet1 = 1 + cbet1, dbet2 = 1 + cbet2;
462 alp12 = 2 * atan2( somg12 * ( sbet1 * dbet2 + sbet2 * dbet1 ),
463 domg12 * ( sbet1 * sbet2 + dbet1 * dbet2 ) );
467 salp12 = salp2 * calp1 - calp2 * salp1,
468 calp12 = calp2 * calp1 + salp2 * salp1;
473 if (salp12 == 0 && calp12 < 0) {
474 salp12 = tiny_ * calp1;
477 alp12 = atan2(salp12, calp12);
480 S12 *= swapp * lonsign * latsign;
493 salp1 *= swapp * lonsign; calp1 *= swapp * latsign;
494 salp2 *= swapp * lonsign; calp2 *= swapp * latsign;
500 Math::real Geodesic::GenInverse(real lat1, real lon1, real lat2, real lon2,
502 real& s12, real& azi1, real& azi2,
503 real& m12, real& M12, real& M21,
506 real salp1, calp1, salp2, calp2,
507 a12 = GenInverse(lat1, lon1, lat2, lon2,
508 outmask, s12, salp1, calp1, salp2, calp2,
518 real lat2, real lon2,
519 unsigned caps)
const {
520 real t, salp1, calp1, salp2, calp2,
521 a12 = GenInverse(lat1, lon1, lat2, lon2,
523 0u, t, salp1, calp1, salp2, calp2,
529 GeodesicLine(*
this, lat1, lon1, azi1, salp1, calp1, caps,
true, a12);
532 void Geodesic::Lengths(
real eps,
real sig12,
535 real cbet1,
real cbet2,
unsigned outmask,
548 real m0x = 0, J12 = 0, A1 = 0, A2 = 0;
562 real B1 = SinCosSeries(
true, ssig2, csig2, Ca, nC1_) -
563 SinCosSeries(
true, ssig1, csig1, Ca, nC1_);
565 s12b = A1 * (sig12 + B1);
567 real B2 = SinCosSeries(
true, ssig2, csig2, Cb, nC2_) -
568 SinCosSeries(
true, ssig1, csig1, Cb, nC2_);
569 J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
573 for (
int l = 1; l <= nC2_; ++l)
574 Cb[l] = A1 * Ca[l] - A2 * Cb[l];
575 J12 = m0x * sig12 + (SinCosSeries(
true, ssig2, csig2, Cb, nC2_) -
576 SinCosSeries(
true, ssig1, csig1, Cb, nC2_));
583 m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) -
587 real csig12 = csig1 * csig2 + ssig1 * ssig2;
588 real t = _ep2 * (cbet1 - cbet2) * (cbet1 + cbet2) / (dn1 + dn2);
589 M12 = csig12 + (t * ssig2 - csig2 * J12) * ssig1 / dn1;
590 M21 = csig12 - (t * ssig1 - csig1 * J12) * ssig2 / dn2;
602 if ( !(q == 0 && r <= 0) ) {
611 disc = S * (S + 2 * r3);
618 T3 += T3 < 0 ? -sqrt(disc) : sqrt(disc);
622 u += T + (T != 0 ? r2 / T : 0);
625 real ang = atan2(sqrt(-disc), -(S + r3));
628 u += 2 * r * cos(ang / 3);
633 uv = u < 0 ? q / (v - u) : u + v,
634 w = (uv - q) / (2 * v);
637 k = uv / (sqrt(uv +
Math::sq(w)) + w);
662 sbet12 = sbet2 * cbet1 - cbet2 * sbet1,
663 cbet12 = cbet2 * cbet1 + sbet2 * sbet1;
664 real sbet12a = sbet2 * cbet1 + cbet2 * sbet1;
665 bool shortline = cbet12 >= 0 && sbet12 <
real(0.5) &&
666 cbet2 * lam12 <
real(0.5);
672 sbetm2 /= sbetm2 +
Math::sq(cbet1 + cbet2);
673 dnm = sqrt(1 + _ep2 * sbetm2);
674 real omg12 = lam12 / (_f1 * dnm);
675 somg12 = sin(omg12); comg12 = cos(omg12);
677 somg12 = slam12; comg12 = clam12;
680 salp1 = cbet2 * somg12;
681 calp1 = comg12 >= 0 ?
682 sbet12 + cbet2 * sbet1 *
Math::sq(somg12) / (1 + comg12) :
683 sbet12a - cbet2 * sbet1 *
Math::sq(somg12) / (1 - comg12);
686 ssig12 = hypot(salp1, calp1),
687 csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
689 if (shortline && ssig12 < _etol2) {
691 salp2 = cbet1 * somg12;
692 calp2 = sbet12 - cbet1 * sbet2 *
693 (comg12 >= 0 ?
Math::sq(somg12) / (1 + comg12) : 1 - comg12);
696 sig12 = atan2(ssig12, csig12);
697 }
else if (abs(_n) >
real(0.1) ||
704 real y, lamscale, betscale;
709 real lam12x = atan2(-slam12, -clam12);
715 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
716 lamscale = _f * cbet1 * A3f(eps) *
Math::pi();
718 betscale = lamscale * cbet1;
720 x = lam12x / lamscale;
721 y = sbet12a / betscale;
725 cbet12a = cbet2 * cbet1 - sbet2 * sbet1,
726 bet12a = atan2(sbet12a, cbet12a);
727 real m12b, m0, dummy;
731 sbet1, -cbet1, dn1, sbet2, cbet2, dn2,
734 x = -1 + m12b / (cbet1 * cbet2 * m0 *
Math::pi());
735 betscale = x < -
real(0.01) ? sbet12a / x :
737 lamscale = betscale / cbet1;
738 y = lam12x / lamscale;
741 if (y > -tol1_ && x > -1 - xthresh_) {
747 calp1 = max(
real(x > -tol1_ ? 0 : -1),
real(x));
785 real k = Astroid(x, y);
787 omg12a = lamscale * ( _f >= 0 ? -x * k/(1 + k) : -y * (1 + k)/k );
788 somg12 = sin(omg12a); comg12 = -cos(omg12a);
790 salp1 = cbet2 * somg12;
791 calp1 = sbet12a - cbet2 * sbet1 *
Math::sq(somg12) / (1 - comg12);
798 salp1 = 1; calp1 = 0;
812 bool diffp,
real& dlam12,
816 if (sbet1 == 0 && calp1 == 0)
823 salp0 = salp1 * cbet1,
824 calp0 = hypot(calp1, salp1 * sbet1);
826 real somg1, comg1, somg2, comg2, somg12, comg12, lam12;
829 ssig1 = sbet1; somg1 = salp0 * sbet1;
830 csig1 = comg1 = calp1 * cbet1;
838 salp2 = cbet2 != cbet1 ? salp0 / cbet2 : salp1;
843 calp2 = cbet2 != cbet1 || abs(sbet2) != -sbet1 ?
846 (cbet2 - cbet1) * (cbet1 + cbet2) :
847 (sbet1 - sbet2) * (sbet1 + sbet2))) / cbet2 :
851 ssig2 = sbet2; somg2 = salp0 * sbet2;
852 csig2 = comg2 = calp2 * cbet2;
857 sig12 = atan2(max(
real(0), csig1 * ssig2 - ssig1 * csig2),
858 csig1 * csig2 + ssig1 * ssig2);
861 somg12 = max(
real(0), comg1 * somg2 - somg1 * comg2);
862 comg12 = comg1 * comg2 + somg1 * somg2;
864 real eta = atan2(somg12 * clam120 - comg12 * slam120,
865 comg12 * clam120 + somg12 * slam120);
868 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
870 B312 = (SinCosSeries(
true, ssig2, csig2, Ca, nC3_-1) -
871 SinCosSeries(
true, ssig1, csig1, Ca, nC3_-1));
872 domg12 = -_f * A3f(eps) * salp0 * (sig12 + B312);
873 lam12 = eta + domg12;
877 dlam12 = - 2 * _f1 * dn1 / sbet1;
880 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
882 dummy, dlam12, dummy, dummy, dummy, Ca);
883 dlam12 *= _f1 / (calp2 * cbet2);
895 void Geodesic::C3f(
real eps,
real c[])
const {
900 for (
int l = 1; l < nC3_; ++l) {
901 int m = nC3_ - l - 1;
909 void Geodesic::C4f(
real eps,
real c[])
const {
914 for (
int l = 0; l < nC4_; ++l) {
915 int m = nC4_ - l - 1;
949 #if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1
950 static const real coeff[] = {
954 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2
955 static const real coeff[] = {
959 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3
960 static const real coeff[] = {
964 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4
965 static const real coeff[] = {
967 25, 64, 256, 4096, 0, 16384,
970 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
972 static_assert(
sizeof(coeff) /
sizeof(
real) == nA1_/2 + 2,
973 "Coefficient array size mismatch in A1m1f");
976 return (t + eps) / (1 - eps);
980 void Geodesic::C1f(
real eps,
real c[]) {
982 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
983 static const real coeff[] = {
991 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
992 static const real coeff[] = {
1002 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1003 static const real coeff[] = {
1015 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1016 static const real coeff[] = {
1030 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1031 static const real coeff[] = {
1033 19, -64, 384, -1024, 2048,
1047 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1048 static const real coeff[] = {
1050 19, -64, 384, -1024, 2048,
1052 7, -18, 128, -256, 4096,
1056 -11, 96, -160, 16384,
1067 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1069 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1070 (nC1_*nC1_ + 7*nC1_ - 2*(nC1_/2)) / 4,
1071 "Coefficient array size mismatch in C1f");
1076 for (
int l = 1; l <= nC1_; ++l) {
1077 int m = (nC1_ - l) / 2;
1078 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1086 void Geodesic::C1pf(
real eps,
real c[]) {
1088 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1089 static const real coeff[] = {
1097 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1098 static const real coeff[] = {
1108 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1109 static const real coeff[] = {
1111 205, -432, 768, 1536,
1121 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1122 static const real coeff[] = {
1124 205, -432, 768, 1536,
1126 4005, -4736, 3840, 12288,
1136 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1137 static const real coeff[] = {
1139 -4879, 9840, -20736, 36864, 73728,
1141 4005, -4736, 3840, 12288,
1143 8703, -7200, 3712, 12288,
1147 -141115, 41604, 92160,
1153 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1154 static const real coeff[] = {
1156 -4879, 9840, -20736, 36864, 73728,
1158 -86171, 120150, -142080, 115200, 368640,
1160 8703, -7200, 3712, 12288,
1162 1082857, -688608, 258720, 737280,
1164 -141115, 41604, 92160,
1166 -2200311, 533134, 860160,
1170 109167851, 82575360,
1173 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1175 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1176 (nC1p_*nC1p_ + 7*nC1p_ - 2*(nC1p_/2)) / 4,
1177 "Coefficient array size mismatch in C1pf");
1182 for (
int l = 1; l <= nC1p_; ++l) {
1183 int m = (nC1p_ - l) / 2;
1184 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1194 #if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1
1195 static const real coeff[] = {
1199 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2
1200 static const real coeff[] = {
1204 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3
1205 static const real coeff[] = {
1207 -11, -28, -192, 0, 256,
1209 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4
1210 static const real coeff[] = {
1212 -375, -704, -1792, -12288, 0, 16384,
1215 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1217 static_assert(
sizeof(coeff) /
sizeof(
real) == nA2_/2 + 2,
1218 "Coefficient array size mismatch in A2m1f");
1221 return (t - eps) / (1 + eps);
1225 void Geodesic::C2f(
real eps,
real c[]) {
1227 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1228 static const real coeff[] = {
1236 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1237 static const real coeff[] = {
1247 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1248 static const real coeff[] = {
1260 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1261 static const real coeff[] = {
1275 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1276 static const real coeff[] = {
1278 41, 64, 128, 1024, 2048,
1292 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1293 static const real coeff[] = {
1295 41, 64, 128, 1024, 2048,
1297 47, 70, 128, 768, 4096,
1301 133, 224, 1120, 16384,
1312 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1314 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1315 (nC2_*nC2_ + 7*nC2_ - 2*(nC2_/2)) / 4,
1316 "Coefficient array size mismatch in C2f");
1321 for (
int l = 1; l <= nC2_; ++l) {
1322 int m = (nC2_ - l) / 2;
1323 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1331 void Geodesic::A3coeff() {
1333 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1334 static const real coeff[] = {
1342 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1343 static const real coeff[] = {
1353 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1354 static const real coeff[] = {
1366 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1367 static const real coeff[] = {
1381 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1382 static const real coeff[] = {
1398 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1399 static const real coeff[] = {
1407 -5, -20, -4, -6, 128,
1418 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1420 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1421 (nA3_*nA3_ + 7*nA3_ - 2*(nA3_/2)) / 4,
1422 "Coefficient array size mismatch in A3f");
1424 for (
int j = nA3_ - 1; j >= 0; --j) {
1425 int m = min(nA3_ - j - 1, j);
1426 _A3x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1433 void Geodesic::C3coeff() {
1435 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1436 static const real coeff[] = {
1444 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1445 static const real coeff[] = {
1461 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1462 static const real coeff[] = {
1484 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1485 static const real coeff[] = {
1517 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1518 static const real coeff[] = {
1562 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1563 static const real coeff[] = {
1597 10, -6, -10, 9, 384,
1607 -7, 20, -28, 14, 1024,
1622 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1624 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1625 ((nC3_-1)*(nC3_*nC3_ + 7*nC3_ - 2*(nC3_/2)))/8,
1626 "Coefficient array size mismatch in C3coeff");
1628 for (
int l = 1; l < nC3_; ++l) {
1629 for (
int j = nC3_ - 1; j >= l; --j) {
1630 int m = min(nC3_ - j - 1, j);
1631 _C3x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1638 void Geodesic::C4coeff() {
1640 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1641 static const real coeff[] = {
1655 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1656 static const real coeff[] = {
1664 4, 24, -84, 210, 315,
1678 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1679 static const real coeff[] = {
1685 1088, -352, -66, 3465,
1687 48, -352, 528, -231, 1155,
1689 16, 44, 264, -924, 2310, 3465,
1695 -896, 704, -198, 10395,
1697 -48, 352, -528, 231, 10395,
1703 320, -352, 132, 17325,
1711 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1712 static const real coeff[] = {
1718 -224, -4784, 1573, 45045,
1720 -10656, 14144, -4576, -858, 45045,
1722 64, 624, -4576, 6864, -3003, 15015,
1724 100, 208, 572, 3432, -12012, 30030, 45045,
1730 5792, 1040, -1287, 135135,
1732 5952, -11648, 9152, -2574, 135135,
1734 -64, -624, 4576, -6864, 3003, 135135,
1740 -8448, 4992, -1144, 225225,
1742 -1440, 4160, -4576, 1716, 225225,
1748 3584, -3328, 1144, 315315,
1756 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1757 static const real coeff[] = {
1763 -4480, 1088, 156, 45045,
1765 10736, -224, -4784, 1573, 45045,
1767 1664, -10656, 14144, -4576, -858, 45045,
1769 16, 64, 624, -4576, 6864, -3003, 15015,
1771 56, 100, 208, 572, 3432, -12012, 30030, 45045,
1777 3840, -2944, 468, 135135,
1779 -10704, 5792, 1040, -1287, 135135,
1781 -768, 5952, -11648, 9152, -2574, 135135,
1783 -16, -64, -624, 4576, -6864, 3003, 135135,
1789 1664, 1856, -936, 225225,
1791 6784, -8448, 4992, -1144, 225225,
1793 128, -1440, 4160, -4576, 1716, 225225,
1799 -2048, 1024, -208, 105105,
1801 -1792, 3584, -3328, 1144, 315315,
1807 3072, -2560, 832, 405405,
1815 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1816 static const real coeff[] = {
1822 20960, -7888, 4947, 765765,
1824 12480, -76160, 18496, 2652, 765765,
1826 -154048, 182512, -3808, -81328, 26741, 765765,
1828 3232, 28288, -181152, 240448, -77792, -14586, 765765,
1830 96, 272, 1088, 10608, -77792, 116688, -51051, 255255,
1832 588, 952, 1700, 3536, 9724, 58344, -204204, 510510, 765765,
1838 -39840, 1904, 255, 2297295,
1840 52608, 65280, -50048, 7956, 2297295,
1842 103744, -181968, 98464, 17680, -21879, 2297295,
1844 -1344, -13056, 101184, -198016, 155584, -43758, 2297295,
1846 -96, -272, -1088, -10608, 77792, -116688, 51051, 2297295,
1850 -928, -612, 3828825,
1852 64256, -28288, 2856, 3828825,
1854 -126528, 28288, 31552, -15912, 3828825,
1856 -41472, 115328, -143616, 84864, -19448, 3828825,
1858 160, 2176, -24480, 70720, -77792, 29172, 3828825,
1862 -16384, 1088, 5360355,
1864 -2560, 30464, -11560, 5360355,
1866 35840, -34816, 17408, -3536, 1786785,
1868 7168, -30464, 60928, -56576, 19448, 5360355,
1872 26624, -8704, 6891885,
1874 -77824, 34816, -6528, 6891885,
1876 -32256, 52224, -43520, 14144, 6891885,
1880 24576, -4352, 8423415,
1882 45056, -34816, 10880, 8423415,
1886 -28672, 8704, 9954945,
1891 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1893 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1894 (nC4_ * (nC4_ + 1) * (nC4_ + 5)) / 6,
1895 "Coefficient array size mismatch in C4coeff");
1897 for (
int l = 0; l < nC4_; ++l) {
1898 for (
int j = nC4_ - 1; j >= l; --j) {
1899 int m = nC4_ - j - 1;
1900 _C4x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
GeographicLib::Math::real real
Header for GeographicLib::GeodesicLine class.
Header for GeographicLib::Geodesic class.
#define GEOGRAPHICLIB_VOLATILE
#define GEOGRAPHICLIB_PANIC
GeodesicLine InverseLine(real lat1, real lon1, real lat2, real lon2, unsigned caps=ALL) const
static const Geodesic & WGS84()
GeodesicLine ArcDirectLine(real lat1, real lon1, real azi1, real a12, unsigned caps=ALL) const
GeodesicLine Line(real lat1, real lon1, real azi1, unsigned caps=ALL) const
GeodesicLine GenDirectLine(real lat1, real lon1, real azi1, bool arcmode, real s12_a12, unsigned caps=ALL) const
friend class GeodesicLine
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
GeodesicLine DirectLine(real lat1, real lon1, real azi1, real s12, unsigned caps=ALL) const
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 void norm(T &x, T &y)
static T polyval(int N, const T p[], T x)
static T AngDiff(T x, T y, T &e)
Namespace for GeographicLib.
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)