35# pragma warning (disable: 4701 4127 5055 5054)
43 : maxit2_(maxit1_ +
Math::digits() + 10)
47 , tiny_(sqrt(numeric_limits<real>::min()))
48 , tol0_(numeric_limits<real>::epsilon())
55 , xthresh_(1000 * tol2_)
61 , _ep2(_e2 /
Math::sq(_f1))
66 Math::eatanhe(real(1), (_f < 0 ? -1 : 1) * sqrt(fabs(_e2))) / _e2))
78 , _etol2(real(0.1) * tol2_ /
79 sqrt( fmax(real(0.001), fabs(_f)) * fmin(real(1), 1 - _f/2) / 2 ))
85 if (!(isfinite(_a) && _a > 0))
87 if (!(isfinite(_b) && _b > 0))
102 const real c[],
int n) {
110 ar = 2 * (cosx - sinx) * (cosx + sinx),
111 y0 = n & 1 ? *--c : 0, y1 = 0;
116 y1 = ar * y0 - y1 + *--c;
117 y0 = ar * y1 - y0 + *--c;
120 ? 2 * sinx * cosx * y0
125 unsigned caps)
const {
130 bool arcmode, real s12_a12,
unsigned outmask,
131 real& lat2, real& lon2, real& azi2,
132 real& s12, real& m12, real& M12, real& M21,
135 return _geodexact.
GenDirect(lat1, lon1, azi1, arcmode, s12_a12, outmask,
137 s12, m12, M12, M21, S12);
142 GenPosition(arcmode, s12_a12, outmask,
143 lat2, lon2, azi2, s12, m12, M12, M21, S12);
147 bool arcmode, real s12_a12,
148 unsigned caps)
const {
155 return GeodesicLine(*
this, lat1, lon1, azi1, salp1, calp1,
156 caps, arcmode, s12_a12);
160 unsigned caps)
const {
165 real a12,
unsigned caps)
const {
170 unsigned outmask,
real& s12,
176 return _geodexact.GenInverse(lat1, lon1, lat2, lon2,
178 salp1, calp1, salp2, calp2,
184 int lonsign = signbit(lon12) ? -1 : 1;
185 lon12 *= lonsign; lon12s *= lonsign;
192 lon12s = (
Math::hd - lon12) - lon12s;
199 int swapp = fabs(lat1) < fabs(lat2) || isnan(lat2) ? -1 : 1;
205 int latsign = signbit(lat1) ? 1 : -1;
220 real sbet1, cbet1, sbet2, cbet2, s12x, m12x;
225 Math::norm(sbet1, cbet1); cbet1 = fmax(tiny_, cbet1);
229 Math::norm(sbet2, cbet2); cbet2 = fmax(tiny_, cbet2);
239 if (cbet1 < -sbet1) {
241 sbet2 = copysign(sbet1, sbet2);
243 if (fabs(sbet2) == -sbet1)
248 dn1 = sqrt(1 + _ep2 *
Math::sq(sbet1)),
249 dn2 = sqrt(1 + _ep2 *
Math::sq(sbet2));
255 bool meridian = lat1 == -
Math::qd || slam12 == 0;
262 calp1 = clam12; salp1 = slam12;
263 calp2 = 1; salp2 = 0;
267 ssig1 = sbet1, csig1 = calp1 * cbet1,
268 ssig2 = sbet2, csig2 = calp2 * cbet2;
271 sig12 = atan2(fmax(
real(0), csig1 * ssig2 - ssig1 * csig2) +
real(0),
272 csig1 * csig2 + ssig1 * ssig2);
275 Lengths(_n, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2,
277 s12x, m12x, dummy, M12, M21, Ca);
291 if (sig12 < 1 || m12x >= 0) {
293 if (sig12 < 3 * tiny_ ||
295 (sig12 < tol0_ && (s12x < 0 || m12x < 0)))
296 sig12 = m12x = s12x = 0;
306 real omg12 = 0, somg12 = 2, comg12 = 0;
309 (_f <= 0 || lon12s >= _f *
Math::hd)) {
312 calp1 = calp2 = 0; salp1 = salp2 = 1;
314 sig12 = omg12 = lam12 / _f1;
315 m12x = _b * sin(sig12);
317 M12 = M21 = cos(sig12);
320 }
else if (!meridian) {
327 sig12 = InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2,
328 lam12, slam12, clam12,
329 salp1, calp1, salp2, calp2, dnm,
334 s12x = sig12 * _b * dnm;
335 m12x =
Math::sq(dnm) * _b * sin(sig12 / dnm);
337 M12 = M21 = cos(sig12 / dnm);
339 omg12 = lam12 / (_f1 * dnm);
355 real ssig1 = 0, csig1 = 0, ssig2 = 0, csig2 = 0, eps = 0, domg12 = 0;
358 real salp1a = tiny_, calp1a = 1, salp1b = tiny_, calp1b = -1;
359 for (
bool tripn =
false, tripb =
false;; ++numit) {
363 real v = Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1,
365 salp2, calp2, sig12, ssig1, csig1, ssig2, csig2,
366 eps, domg12, numit < maxit1_, dv, Ca);
369 !(fabs(v) >= (tripn ? 8 : 1) * tol0_) ||
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) {
386 sdalp1 = sin(dalp1), cdalp1 = cos(dalp1),
387 nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
389 calp1 = calp1 * cdalp1 - salp1 * sdalp1;
395 tripn = fabs(v) <= 16 * tol0_;
408 salp1 = (salp1a + salp1b)/2;
409 calp1 = (calp1a + calp1b)/2;
412 tripb = (fabs(salp1a - salp1) + (calp1a - calp1) < tolb_ ||
413 fabs(salp1 - salp1b) + (calp1 - calp1b) < tolb_);
419 unsigned lengthmask = outmask |
421 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
422 cbet1, cbet2, lengthmask, s12x, m12x, dummy, M12, M21, Ca);
427 if (outmask &
AREA) {
429 real sdomg12 = sin(domg12), cdomg12 = cos(domg12);
430 somg12 = slam12 * cdomg12 - clam12 * sdomg12;
431 comg12 = clam12 * cdomg12 + slam12 * sdomg12;
437 s12 =
real(0) + s12x;
440 m12 =
real(0) + m12x;
442 if (outmask &
AREA) {
445 salp0 = salp1 * cbet1,
446 calp0 = hypot(calp1, salp1 * sbet1);
448 if (calp0 != 0 && salp0 != 0) {
451 ssig1 = sbet1, csig1 = calp1 * cbet1,
452 ssig2 = sbet2, csig2 = calp2 * cbet2,
454 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2),
456 A4 =
Math::sq(_a) * calp0 * salp0 * _e2;
461 B41 = SinCosSeries(
false, ssig1, csig1, Ca, nC4_),
462 B42 = SinCosSeries(
false, ssig2, csig2, Ca, nC4_);
463 S12 = A4 * (B42 - B41);
467 if (!meridian && somg12 == 2) {
468 somg12 = sin(omg12); comg12 = cos(omg12);
473 comg12 > -
real(0.7071) &&
474 sbet2 - sbet1 <
real(1.75)) {
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 ) );
484 salp12 = salp2 * calp1 - calp2 * salp1,
485 calp12 = calp2 * calp1 + salp2 * salp1;
490 if (salp12 == 0 && calp12 < 0) {
491 salp12 = tiny_ * calp1;
494 alp12 = atan2(salp12, calp12);
497 S12 *= swapp * lonsign * latsign;
510 salp1 *= swapp * lonsign; calp1 *= swapp * latsign;
511 salp2 *= swapp * lonsign; calp2 *= swapp * latsign;
516 Math::real Geodesic::GenInverse(real lat1, real lon1, real lat2, real lon2,
518 real& s12, real& azi1, real& azi2,
519 real& m12, real& M12, real& M21,
522 real salp1, calp1, salp2, calp2,
523 a12 = GenInverse(lat1, lon1, lat2, lon2,
524 outmask, s12, salp1, calp1, salp2, calp2,
534 real lat2, real lon2,
535 unsigned caps)
const {
536 real t, salp1, calp1, salp2, calp2,
537 a12 = GenInverse(lat1, lon1, lat2, lon2,
539 0u, t, salp1, calp1, salp2, calp2,
545 GeodesicLine(*
this, lat1, lon1, azi1, salp1, calp1, caps,
true, a12);
548 void Geodesic::Lengths(
real eps,
real sig12,
551 real cbet1,
real cbet2,
unsigned outmask,
564 real m0x = 0, J12 = 0, A1 = 0, A2 = 0;
578 real B1 = SinCosSeries(
true, ssig2, csig2, Ca, nC1_) -
579 SinCosSeries(
true, ssig1, csig1, Ca, nC1_);
581 s12b = A1 * (sig12 + B1);
583 real B2 = SinCosSeries(
true, ssig2, csig2, Cb, nC2_) -
584 SinCosSeries(
true, ssig1, csig1, Cb, nC2_);
585 J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
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_));
599 m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) -
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;
618 if ( !(q == 0 && r <= 0) ) {
627 disc = S * (S + 2 * r3);
634 T3 += T3 < 0 ? -sqrt(disc) : sqrt(disc);
638 u += T + (T != 0 ? r2 / T : 0);
641 real ang = atan2(sqrt(-disc), -(S + r3));
644 u += 2 * r * cos(ang / 3);
649 uv = u < 0 ? q / (v - u) : u + v,
650 w = (uv - q) / (2 * v);
653 k = uv / (sqrt(uv +
Math::sq(w)) + w);
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);
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);
693 somg12 = slam12; comg12 = clam12;
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);
702 ssig12 = hypot(salp1, calp1),
703 csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
705 if (shortline && ssig12 < _etol2) {
707 salp2 = cbet1 * somg12;
708 calp2 = sbet12 - cbet1 * sbet2 *
709 (comg12 >= 0 ?
Math::sq(somg12) / (1 + comg12) : 1 - comg12);
712 sig12 = atan2(ssig12, csig12);
713 }
else if (fabs(_n) >
real(0.1) ||
720 real x, y, lamscale, betscale;
721 real lam12x = atan2(-slam12, -clam12);
727 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
728 lamscale = _f * cbet1 * A3f(eps) *
Math::pi();
730 betscale = lamscale * cbet1;
732 x = lam12x / lamscale;
733 y = sbet12a / betscale;
737 cbet12a = cbet2 * cbet1 - sbet2 * sbet1,
738 bet12a = atan2(sbet12a, cbet12a);
739 real m12b, m0, dummy;
743 sbet1, -cbet1, dn1, sbet2, cbet2, dn2,
746 x = -1 + m12b / (cbet1 * cbet2 * m0 *
Math::pi());
747 betscale = x < -
real(0.01) ? sbet12a / x :
749 lamscale = betscale / cbet1;
750 y = lam12x / lamscale;
753 if (y > -tol1_ && x > -1 - xthresh_) {
757 salp1 = fmin(
real(1), -x); calp1 = - sqrt(1 -
Math::sq(salp1));
759 calp1 = fmax(
real(x > -tol1_ ? 0 : -1), x);
797 real k = Astroid(x, y);
799 omg12a = lamscale * ( _f >= 0 ? -x * k/(1 + k) : -y * (1 + k)/k );
800 somg12 = sin(omg12a); comg12 = -cos(omg12a);
802 salp1 = cbet2 * somg12;
803 calp1 = sbet12a - cbet2 * sbet1 *
Math::sq(somg12) / (1 - comg12);
810 salp1 = 1; calp1 = 0;
824 bool diffp,
real& dlam12,
828 if (sbet1 == 0 && calp1 == 0)
835 salp0 = salp1 * cbet1,
836 calp0 = hypot(calp1, salp1 * sbet1);
838 real somg1, comg1, somg2, comg2, somg12, comg12, lam12;
841 ssig1 = sbet1; somg1 = salp0 * sbet1;
842 csig1 = comg1 = calp1 * cbet1;
850 salp2 = cbet2 != cbet1 ? salp0 / cbet2 : salp1;
855 calp2 = cbet2 != cbet1 || fabs(sbet2) != -sbet1 ?
858 (cbet2 - cbet1) * (cbet1 + cbet2) :
859 (sbet1 - sbet2) * (sbet1 + sbet2))) / cbet2 :
863 ssig2 = sbet2; somg2 = salp0 * sbet2;
864 csig2 = comg2 = calp2 * cbet2;
869 sig12 = atan2(fmax(
real(0), csig1 * ssig2 - ssig1 * csig2) +
real(0),
870 csig1 * csig2 + ssig1 * ssig2);
873 somg12 = fmax(
real(0), comg1 * somg2 - somg1 * comg2) +
real(0);
874 comg12 = comg1 * comg2 + somg1 * somg2;
876 real eta = atan2(somg12 * clam120 - comg12 * slam120,
877 comg12 * clam120 + somg12 * slam120);
880 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
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;
889 dlam12 = - 2 * _f1 * dn1 / sbet1;
892 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
894 dummy, dlam12, dummy, dummy, dummy, Ca);
895 dlam12 *= _f1 / (calp2 * cbet2);
907 void Geodesic::C3f(
real eps,
real c[])
const {
912 for (
int l = 1; l < nC3_; ++l) {
913 int m = nC3_ - l - 1;
921 void Geodesic::C4f(
real eps,
real c[])
const {
926 for (
int l = 0; l < nC4_; ++l) {
927 int m = nC4_ - l - 1;
961#if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1
962 static const real coeff[] = {
966#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2
967 static const real coeff[] = {
971#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3
972 static const real coeff[] = {
976#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4
977 static const real coeff[] = {
979 25, 64, 256, 4096, 0, 16384,
982#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
984 static_assert(
sizeof(coeff) /
sizeof(
real) == nA1_/2 + 2,
985 "Coefficient array size mismatch in A1m1f");
988 return (t + eps) / (1 - eps);
992 void Geodesic::C1f(
real eps,
real c[]) {
994#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
995 static const real coeff[] = {
1003#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1004 static const real coeff[] = {
1014#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1015 static const real coeff[] = {
1027#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1028 static const real coeff[] = {
1042#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1043 static const real coeff[] = {
1045 19, -64, 384, -1024, 2048,
1059#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1060 static const real coeff[] = {
1062 19, -64, 384, -1024, 2048,
1064 7, -18, 128, -256, 4096,
1068 -11, 96, -160, 16384,
1079#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1081 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1082 (nC1_*nC1_ + 7*nC1_ - 2*(nC1_/2)) / 4,
1083 "Coefficient array size mismatch in C1f");
1088 for (
int l = 1; l <= nC1_; ++l) {
1089 int m = (nC1_ - l) / 2;
1090 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1098 void Geodesic::C1pf(
real eps,
real c[]) {
1100#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1101 static const real coeff[] = {
1109#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1110 static const real coeff[] = {
1120#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1121 static const real coeff[] = {
1123 205, -432, 768, 1536,
1133#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1134 static const real coeff[] = {
1136 205, -432, 768, 1536,
1138 4005, -4736, 3840, 12288,
1148#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1149 static const real coeff[] = {
1151 -4879, 9840, -20736, 36864, 73728,
1153 4005, -4736, 3840, 12288,
1155 8703, -7200, 3712, 12288,
1159 -141115, 41604, 92160,
1165#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1166 static const real coeff[] = {
1168 -4879, 9840, -20736, 36864, 73728,
1170 -86171, 120150, -142080, 115200, 368640,
1172 8703, -7200, 3712, 12288,
1174 1082857, -688608, 258720, 737280,
1176 -141115, 41604, 92160,
1178 -2200311, 533134, 860160,
1182 109167851, 82575360,
1185#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1187 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1188 (nC1p_*nC1p_ + 7*nC1p_ - 2*(nC1p_/2)) / 4,
1189 "Coefficient array size mismatch in C1pf");
1194 for (
int l = 1; l <= nC1p_; ++l) {
1195 int m = (nC1p_ - l) / 2;
1196 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1206#if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1
1207 static const real coeff[] = {
1211#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2
1212 static const real coeff[] = {
1216#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3
1217 static const real coeff[] = {
1219 -11, -28, -192, 0, 256,
1221#elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4
1222 static const real coeff[] = {
1224 -375, -704, -1792, -12288, 0, 16384,
1227#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1229 static_assert(
sizeof(coeff) /
sizeof(
real) == nA2_/2 + 2,
1230 "Coefficient array size mismatch in A2m1f");
1233 return (t - eps) / (1 + eps);
1237 void Geodesic::C2f(
real eps,
real c[]) {
1239#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1240 static const real coeff[] = {
1248#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1249 static const real coeff[] = {
1259#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1260 static const real coeff[] = {
1272#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1273 static const real coeff[] = {
1287#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1288 static const real coeff[] = {
1290 41, 64, 128, 1024, 2048,
1304#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1305 static const real coeff[] = {
1307 41, 64, 128, 1024, 2048,
1309 47, 70, 128, 768, 4096,
1313 133, 224, 1120, 16384,
1324#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1326 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1327 (nC2_*nC2_ + 7*nC2_ - 2*(nC2_/2)) / 4,
1328 "Coefficient array size mismatch in C2f");
1333 for (
int l = 1; l <= nC2_; ++l) {
1334 int m = (nC2_ - l) / 2;
1335 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1343 void Geodesic::A3coeff() {
1345#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1346 static const real coeff[] = {
1354#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1355 static const real coeff[] = {
1365#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1366 static const real coeff[] = {
1378#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1379 static const real coeff[] = {
1393#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1394 static const real coeff[] = {
1410#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1411 static const real coeff[] = {
1419 -5, -20, -4, -6, 128,
1430#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1432 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1433 (nA3_*nA3_ + 7*nA3_ - 2*(nA3_/2)) / 4,
1434 "Coefficient array size mismatch in A3f");
1436 for (
int j = nA3_ - 1; j >= 0; --j) {
1437 int m = min(nA3_ - j - 1, j);
1438 _aA3x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1445 void Geodesic::C3coeff() {
1447#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1448 static const real coeff[] = {
1456#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1457 static const real coeff[] = {
1473#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1474 static const real coeff[] = {
1496#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1497 static const real coeff[] = {
1529#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1530 static const real coeff[] = {
1574#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1575 static const real coeff[] = {
1609 10, -6, -10, 9, 384,
1619 -7, 20, -28, 14, 1024,
1634#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
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");
1640 for (
int l = 1; l < nC3_; ++l) {
1641 for (
int j = nC3_ - 1; j >= l; --j) {
1642 int m = min(nC3_ - j - 1, j);
1643 _cC3x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1650 void Geodesic::C4coeff() {
1652#if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1653 static const real coeff[] = {
1667#elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1668 static const real coeff[] = {
1676 4, 24, -84, 210, 315,
1690#elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1691 static const real coeff[] = {
1697 1088, -352, -66, 3465,
1699 48, -352, 528, -231, 1155,
1701 16, 44, 264, -924, 2310, 3465,
1707 -896, 704, -198, 10395,
1709 -48, 352, -528, 231, 10395,
1715 320, -352, 132, 17325,
1723#elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1724 static const real coeff[] = {
1730 -224, -4784, 1573, 45045,
1732 -10656, 14144, -4576, -858, 45045,
1734 64, 624, -4576, 6864, -3003, 15015,
1736 100, 208, 572, 3432, -12012, 30030, 45045,
1742 5792, 1040, -1287, 135135,
1744 5952, -11648, 9152, -2574, 135135,
1746 -64, -624, 4576, -6864, 3003, 135135,
1752 -8448, 4992, -1144, 225225,
1754 -1440, 4160, -4576, 1716, 225225,
1760 3584, -3328, 1144, 315315,
1768#elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1769 static const real coeff[] = {
1775 -4480, 1088, 156, 45045,
1777 10736, -224, -4784, 1573, 45045,
1779 1664, -10656, 14144, -4576, -858, 45045,
1781 16, 64, 624, -4576, 6864, -3003, 15015,
1783 56, 100, 208, 572, 3432, -12012, 30030, 45045,
1789 3840, -2944, 468, 135135,
1791 -10704, 5792, 1040, -1287, 135135,
1793 -768, 5952, -11648, 9152, -2574, 135135,
1795 -16, -64, -624, 4576, -6864, 3003, 135135,
1801 1664, 1856, -936, 225225,
1803 6784, -8448, 4992, -1144, 225225,
1805 128, -1440, 4160, -4576, 1716, 225225,
1811 -2048, 1024, -208, 105105,
1813 -1792, 3584, -3328, 1144, 315315,
1819 3072, -2560, 832, 405405,
1827#elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1828 static const real coeff[] = {
1834 20960, -7888, 4947, 765765,
1836 12480, -76160, 18496, 2652, 765765,
1838 -154048, 182512, -3808, -81328, 26741, 765765,
1840 3232, 28288, -181152, 240448, -77792, -14586, 765765,
1842 96, 272, 1088, 10608, -77792, 116688, -51051, 255255,
1844 588, 952, 1700, 3536, 9724, 58344, -204204, 510510, 765765,
1850 -39840, 1904, 255, 2297295,
1852 52608, 65280, -50048, 7956, 2297295,
1854 103744, -181968, 98464, 17680, -21879, 2297295,
1856 -1344, -13056, 101184, -198016, 155584, -43758, 2297295,
1858 -96, -272, -1088, -10608, 77792, -116688, 51051, 2297295,
1862 -928, -612, 3828825,
1864 64256, -28288, 2856, 3828825,
1866 -126528, 28288, 31552, -15912, 3828825,
1868 -41472, 115328, -143616, 84864, -19448, 3828825,
1870 160, 2176, -24480, 70720, -77792, 29172, 3828825,
1874 -16384, 1088, 5360355,
1876 -2560, 30464, -11560, 5360355,
1878 35840, -34816, 17408, -3536, 1786785,
1880 7168, -30464, 60928, -56576, 19448, 5360355,
1884 26624, -8704, 6891885,
1886 -77824, 34816, -6528, 6891885,
1888 -32256, 52224, -43520, 14144, 6891885,
1892 24576, -4352, 8423415,
1894 45056, -34816, 10880, 8423415,
1898 -28672, 8704, 9954945,
1903#error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1905 static_assert(
sizeof(coeff) /
sizeof(
real) ==
1906 (nC4_ * (nC4_ + 1) * (nC4_ + 5)) / 6,
1907 "Coefficient array size mismatch in C4coeff");
1909 for (
int l = 0; l < nC4_; ++l) {
1910 for (
int j = nC4_ - 1; j >= l; --j) {
1911 int m = nC4_ - j - 1;
1912 _cC4x[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.
Exact geodesic calculations.
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 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
Geodesic(real a, real f, bool exact=false)
Exception handling for GeographicLib.
Mathematical functions needed by GeographicLib.
static void sincosd(T x, T &sinx, T &cosx)
static T atan2d(T y, T x)
static void norm(T &x, T &y)
static T AngNormalize(T x)
static void sincosde(T x, T t, T &sinx, T &cosx)
static T polyval(int N, const T p[], T x)
static T AngDiff(T x, T y, T &e)
@ hd
degrees per half turn
@ qd
degrees per quarter turn
Namespace for GeographicLib.
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)