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(0.1 * tol2_ /
78 sqrt( max(real(0.001), abs(_f)) * min(real(1), 1 - _f/2) / 2 ))
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
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);
275 if (sig12 < 1 || m12x >= 0) {
277 if (sig12 < 3 * tiny_)
278 sig12 = m12x = s12x = 0;
288 real omg12 = 0, somg12 = 2, comg12 = 0;
291 (_f <= 0 || lon12s >= _f * 180)) {
294 calp1 = calp2 = 0; salp1 = salp2 = 1;
296 sig12 = omg12 = lam12 / _f1;
297 m12x = _b * sin(sig12);
299 M12 = M21 = cos(sig12);
302 }
else if (!meridian) {
309 sig12 = InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2,
310 lam12, slam12, clam12,
311 salp1, calp1, salp2, calp2, dnm,
316 s12x = sig12 * _b * dnm;
317 m12x =
Math::sq(dnm) * _b * sin(sig12 / dnm);
319 M12 = M21 = cos(sig12 / dnm);
321 omg12 = lam12 / (_f1 * dnm);
337 real ssig1 = 0, csig1 = 0, ssig2 = 0, csig2 = 0, eps = 0;
340 real salp1a = tiny_, calp1a = 1, salp1b = tiny_, calp1b = -1;
341 for (
bool tripn =
false, tripb =
false;
347 real v = Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1,
349 salp2, calp2, sig12, ssig1, csig1, ssig2, csig2,
350 eps, somg12, comg12, numit < maxit1_, dv, Ca);
352 if (tripb || !(abs(v) >= (tripn ? 8 : 1) * tol0_))
break;
354 if (v > 0 && (numit > maxit1_ || calp1/salp1 > calp1b/salp1b))
355 { salp1b = salp1; calp1b = calp1; }
356 else if (v < 0 && (numit > maxit1_ || calp1/salp1 < calp1a/salp1a))
357 { salp1a = salp1; calp1a = calp1; }
358 if (numit < maxit1_ && dv > 0) {
362 sdalp1 = sin(dalp1), cdalp1 = cos(dalp1),
363 nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
364 if (nsalp1 > 0 && abs(dalp1) <
Math::pi()) {
365 calp1 = calp1 * cdalp1 - salp1 * sdalp1;
371 tripn = abs(v) <= 16 * tol0_;
383 salp1 = (salp1a + salp1b)/2;
384 calp1 = (calp1a + calp1b)/2;
387 tripb = (abs(salp1a - salp1) + (calp1a - calp1) < tolb_ ||
388 abs(salp1 - salp1b) + (calp1 - calp1b) < tolb_);
394 unsigned lengthmask = outmask |
396 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
397 cbet1, cbet2, lengthmask, s12x, m12x, dummy, M12, M21, Ca);
411 if (outmask &
AREA) {
414 salp0 = salp1 * cbet1,
417 if (calp0 != 0 && salp0 != 0) {
420 ssig1 = sbet1, csig1 = calp1 * cbet1,
421 ssig2 = sbet2, csig2 = calp2 * cbet2,
423 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2),
425 A4 =
Math::sq(_a) * calp0 * salp0 * _e2;
430 B41 = SinCosSeries(
false, ssig1, csig1, Ca, nC4_),
431 B42 = SinCosSeries(
false, ssig2, csig2, Ca, nC4_);
432 S12 = A4 * (B42 - B41);
439 somg12 = sin(omg12); comg12 = cos(omg12);
446 comg12 > -
real(0.7071) &&
447 sbet2 - sbet1 <
real(1.75)) {
451 real domg12 = 1 + comg12, dbet1 = 1 + cbet1, dbet2 = 1 + cbet2;
452 alp12 = 2 * atan2( somg12 * ( sbet1 * dbet2 + sbet2 * dbet1 ),
453 domg12 * ( sbet1 * sbet2 + dbet1 * dbet2 ) );
457 salp12 = salp2 * calp1 - calp2 * salp1,
458 calp12 = calp2 * calp1 + salp2 * salp1;
463 if (salp12 == 0 && calp12 < 0) {
464 salp12 = tiny_ * calp1;
467 alp12 = atan2(salp12, calp12);
470 S12 *= swapp * lonsign * latsign;
483 salp1 *= swapp * lonsign; calp1 *= swapp * latsign;
484 salp2 *= swapp * lonsign; calp2 *= swapp * latsign;
490 Math::real Geodesic::GenInverse(real lat1, real lon1, real lat2, real lon2,
492 real& s12, real& azi1, real& azi2,
493 real& m12, real& M12, real& M21, real& S12)
496 real salp1, calp1, salp2, calp2,
497 a12 = GenInverse(lat1, lon1, lat2, lon2,
498 outmask, s12, salp1, calp1, salp2, calp2,
508 unsigned caps)
const {
509 real t, salp1, calp1, salp2, calp2,
510 a12 = GenInverse(lat1, lon1, lat2, lon2,
512 0u, t, salp1, calp1, salp2, calp2,
517 return GeodesicLine(*
this, lat1, lon1, azi1, salp1, calp1, caps,
true, a12);
520 void Geodesic::Lengths(
real eps,
real sig12,
523 real cbet1,
real cbet2,
unsigned outmask,
535 real m0x = 0, J12 = 0, A1 = 0, A2 = 0;
548 if (outmask & DISTANCE) {
549 real B1 = SinCosSeries(
true, ssig2, csig2, Ca, nC1_) -
550 SinCosSeries(
true, ssig1, csig1, Ca, nC1_);
552 s12b = A1 * (sig12 + B1);
554 real B2 = SinCosSeries(
true, ssig2, csig2, Cb, nC2_) -
555 SinCosSeries(
true, ssig1, csig1, Cb, nC2_);
556 J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
560 for (
int l = 1; l <= nC2_; ++l)
561 Cb[l] = A1 * Ca[l] - A2 * Cb[l];
562 J12 = m0x * sig12 + (SinCosSeries(
true, ssig2, csig2, Cb, nC2_) -
563 SinCosSeries(
true, ssig1, csig1, Cb, nC2_));
565 if (outmask & REDUCEDLENGTH) {
570 m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) -
574 real csig12 = csig1 * csig2 + ssig1 * ssig2;
575 real t = _ep2 * (cbet1 - cbet2) * (cbet1 + cbet2) / (dn1 + dn2);
576 M12 = csig12 + (t * ssig2 - csig2 * J12) * ssig1 / dn1;
577 M21 = csig12 - (t * ssig1 - csig1 * J12) * ssig2 / dn2;
589 if ( !(q == 0 && r <= 0) ) {
598 disc = S * (S + 2 * r3);
605 T3 += T3 < 0 ? -sqrt(disc) : sqrt(disc);
609 u += T + (T ? r2 / T : 0);
612 real ang = atan2(sqrt(-disc), -(S + r3));
615 u += 2 * r * cos(ang / 3);
620 uv = u < 0 ? q / (v - u) : u + v,
621 w = (uv - q) / (2 * v);
624 k = uv / (sqrt(uv +
Math::sq(w)) + w);
649 sbet12 = sbet2 * cbet1 - cbet2 * sbet1,
650 cbet12 = cbet2 * cbet1 + sbet2 * sbet1;
651 #if defined(__GNUC__) && __GNUC__ == 4 && \
652 (__GNUC_MINOR__ < 6 || defined(__MINGW32__))
666 real sbet12a = sbet2 * cbet1 + cbet2 * sbet1;
668 bool shortline = cbet12 >= 0 && sbet12 <
real(0.5) &&
669 cbet2 * lam12 <
real(0.5);
675 sbetm2 /= sbetm2 +
Math::sq(cbet1 + cbet2);
676 dnm = sqrt(1 + _ep2 * sbetm2);
677 real omg12 = lam12 / (_f1 * dnm);
678 somg12 = sin(omg12); comg12 = cos(omg12);
680 somg12 = slam12; comg12 = clam12;
683 salp1 = cbet2 * somg12;
684 calp1 = comg12 >= 0 ?
685 sbet12 + cbet2 * sbet1 *
Math::sq(somg12) / (1 + comg12) :
686 sbet12a - cbet2 * sbet1 *
Math::sq(somg12) / (1 - comg12);
690 csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
692 if (shortline && ssig12 < _etol2) {
694 salp2 = cbet1 * somg12;
695 calp2 = sbet12 - cbet1 * sbet2 *
696 (comg12 >= 0 ?
Math::sq(somg12) / (1 + comg12) : 1 - comg12);
699 sig12 = atan2(ssig12, csig12);
700 }
else if (abs(_n) >
real(0.1) ||
707 real y, lamscale, betscale;
712 real lam12x = atan2(-slam12, -clam12);
718 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
719 lamscale = _f * cbet1 * A3f(eps) *
Math::pi();
721 betscale = lamscale * cbet1;
723 x = lam12x / lamscale;
724 y = sbet12a / betscale;
728 cbet12a = cbet2 * cbet1 - sbet2 * sbet1,
729 bet12a = atan2(sbet12a, cbet12a);
730 real m12b, m0, dummy;
734 sbet1, -cbet1, dn1, sbet2, cbet2, dn2,
735 cbet1, cbet2, REDUCEDLENGTH, dummy, m12b, m0, dummy, dummy, Ca);
736 x = -1 + m12b / (cbet1 * cbet2 * m0 *
Math::pi());
737 betscale = x < -
real(0.01) ? sbet12a / x :
739 lamscale = betscale / cbet1;
740 y = lam12x / lamscale;
743 if (y > -tol1_ && x > -1 - xthresh_) {
749 calp1 = max(
real(x > -tol1_ ? 0 : -1),
real(x));
787 real k = Astroid(x, y);
789 omg12a = lamscale * ( _f >= 0 ? -x * k/(1 + k) : -y * (1 + k)/k );
790 somg12 = sin(omg12a); comg12 = -cos(omg12a);
792 salp1 = cbet2 * somg12;
793 calp1 = sbet12a - cbet2 * sbet1 *
Math::sq(somg12) / (1 - comg12);
800 salp1 = 1; calp1 = 0;
814 bool diffp,
real& dlam12,
818 if (sbet1 == 0 && calp1 == 0)
825 salp0 = salp1 * cbet1,
828 real somg1, comg1, somg2, comg2, lam12;
831 ssig1 = sbet1; somg1 = salp0 * sbet1;
832 csig1 = comg1 = calp1 * cbet1;
840 salp2 = cbet2 != cbet1 ? salp0 / cbet2 : salp1;
845 calp2 = cbet2 != cbet1 || abs(sbet2) != -sbet1 ?
848 (cbet2 - cbet1) * (cbet1 + cbet2) :
849 (sbet1 - sbet2) * (sbet1 + sbet2))) / cbet2 :
853 ssig2 = sbet2; somg2 = salp0 * sbet2;
854 csig2 = comg2 = calp2 * cbet2;
859 sig12 = atan2(max(
real(0), csig1 * ssig2 - ssig1 * csig2),
860 csig1 * csig2 + ssig1 * ssig2);
863 somg12 = max(
real(0), comg1 * somg2 - somg1 * comg2);
864 comg12 = comg1 * comg2 + somg1 * somg2;
866 real eta = atan2(somg12 * clam120 - comg12 * slam120,
867 comg12 * clam120 + somg12 * slam120);
870 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
872 B312 = (SinCosSeries(
true, ssig2, csig2, Ca, nC3_-1) -
873 SinCosSeries(
true, ssig1, csig1, Ca, nC3_-1));
874 lam12 = eta - _f * A3f(eps) * salp0 * (sig12 + B312);
878 dlam12 = - 2 * _f1 * dn1 / sbet1;
881 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
882 cbet1, cbet2, REDUCEDLENGTH,
883 dummy, dlam12, dummy, dummy, dummy, Ca);
884 dlam12 *= _f1 / (calp2 * cbet2);
896 void Geodesic::C3f(
real eps,
real c[])
const {
901 for (
int l = 1; l < nC3_; ++l) {
902 int m = nC3_ - l - 1;
910 void Geodesic::C4f(
real eps,
real c[])
const {
915 for (
int l = 0; l < nC4_; ++l) {
916 int m = nC4_ - l - 1;
950 #if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1
951 static const real coeff[] = {
955 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2
956 static const real coeff[] = {
960 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3
961 static const real coeff[] = {
965 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4
966 static const real coeff[] = {
968 25, 64, 256, 4096, 0, 16384,
971 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
973 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(
real) == nA1_/2 + 2,
974 "Coefficient array size mismatch in A1m1f");
977 return (t + eps) / (1 - eps);
981 void Geodesic::C1f(
real eps,
real c[]) {
983 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
984 static const real coeff[] = {
992 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
993 static const real coeff[] = {
1003 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1004 static const real coeff[] = {
1016 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1017 static const real coeff[] = {
1031 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1032 static const real coeff[] = {
1034 19, -64, 384, -1024, 2048,
1048 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1049 static const real coeff[] = {
1051 19, -64, 384, -1024, 2048,
1053 7, -18, 128, -256, 4096,
1057 -11, 96, -160, 16384,
1068 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1070 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(
real) ==
1071 (nC1_*nC1_ + 7*nC1_ - 2*(nC1_/2)) / 4,
1072 "Coefficient array size mismatch in C1f");
1077 for (
int l = 1; l <= nC1_; ++l) {
1078 int m = (nC1_ - l) / 2;
1079 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1087 void Geodesic::C1pf(
real eps,
real c[]) {
1089 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1090 static const real coeff[] = {
1098 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1099 static const real coeff[] = {
1109 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1110 static const real coeff[] = {
1112 205, -432, 768, 1536,
1122 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1123 static const real coeff[] = {
1125 205, -432, 768, 1536,
1127 4005, -4736, 3840, 12288,
1137 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1138 static const real coeff[] = {
1140 -4879, 9840, -20736, 36864, 73728,
1142 4005, -4736, 3840, 12288,
1144 8703, -7200, 3712, 12288,
1148 -141115, 41604, 92160,
1154 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1155 static const real coeff[] = {
1157 -4879, 9840, -20736, 36864, 73728,
1159 -86171, 120150, -142080, 115200, 368640,
1161 8703, -7200, 3712, 12288,
1163 1082857, -688608, 258720, 737280,
1165 -141115, 41604, 92160,
1167 -2200311, 533134, 860160,
1171 109167851, 82575360,
1174 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1176 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(
real) ==
1177 (nC1p_*nC1p_ + 7*nC1p_ - 2*(nC1p_/2)) / 4,
1178 "Coefficient array size mismatch in C1pf");
1183 for (
int l = 1; l <= nC1p_; ++l) {
1184 int m = (nC1p_ - l) / 2;
1185 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1195 #if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1
1196 static const real coeff[] = {
1200 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2
1201 static const real coeff[] = {
1205 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3
1206 static const real coeff[] = {
1208 -11, -28, -192, 0, 256,
1210 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4
1211 static const real coeff[] = {
1213 -375, -704, -1792, -12288, 0, 16384,
1216 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1218 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(
real) == nA2_/2 + 2,
1219 "Coefficient array size mismatch in A2m1f");
1222 return (t - eps) / (1 + eps);
1226 void Geodesic::C2f(
real eps,
real c[]) {
1228 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1229 static const real coeff[] = {
1237 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1238 static const real coeff[] = {
1248 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1249 static const real coeff[] = {
1261 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1262 static const real coeff[] = {
1276 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1277 static const real coeff[] = {
1279 41, 64, 128, 1024, 2048,
1293 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1294 static const real coeff[] = {
1296 41, 64, 128, 1024, 2048,
1298 47, 70, 128, 768, 4096,
1302 133, 224, 1120, 16384,
1313 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1315 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(
real) ==
1316 (nC2_*nC2_ + 7*nC2_ - 2*(nC2_/2)) / 4,
1317 "Coefficient array size mismatch in C2f");
1322 for (
int l = 1; l <= nC2_; ++l) {
1323 int m = (nC2_ - l) / 2;
1324 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1332 void Geodesic::A3coeff() {
1334 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1335 static const real coeff[] = {
1343 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1344 static const real coeff[] = {
1354 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1355 static const real coeff[] = {
1367 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1368 static const real coeff[] = {
1382 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1383 static const real coeff[] = {
1399 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1400 static const real coeff[] = {
1408 -5, -20, -4, -6, 128,
1419 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1421 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(
real) ==
1422 (nA3_*nA3_ + 7*nA3_ - 2*(nA3_/2)) / 4,
1423 "Coefficient array size mismatch in A3f");
1425 for (
int j = nA3_ - 1; j >= 0; --j) {
1426 int m = min(nA3_ - j - 1, j);
1427 _A3x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1434 void Geodesic::C3coeff() {
1436 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1437 static const real coeff[] = {
1445 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1446 static const real coeff[] = {
1462 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1463 static const real coeff[] = {
1485 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1486 static const real coeff[] = {
1518 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1519 static const real coeff[] = {
1563 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1564 static const real coeff[] = {
1598 10, -6, -10, 9, 384,
1608 -7, 20, -28, 14, 1024,
1623 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1625 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(
real) ==
1626 ((nC3_-1)*(nC3_*nC3_ + 7*nC3_ - 2*(nC3_/2)))/8,
1627 "Coefficient array size mismatch in C3coeff");
1629 for (
int l = 1; l < nC3_; ++l) {
1630 for (
int j = nC3_ - 1; j >= l; --j) {
1631 int m = min(nC3_ - j - 1, j);
1632 _C3x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1639 void Geodesic::C4coeff() {
1641 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3
1642 static const real coeff[] = {
1656 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4
1657 static const real coeff[] = {
1665 4, 24, -84, 210, 315,
1679 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5
1680 static const real coeff[] = {
1686 1088, -352, -66, 3465,
1688 48, -352, 528, -231, 1155,
1690 16, 44, 264, -924, 2310, 3465,
1696 -896, 704, -198, 10395,
1698 -48, 352, -528, 231, 10395,
1704 320, -352, 132, 17325,
1712 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6
1713 static const real coeff[] = {
1719 -224, -4784, 1573, 45045,
1721 -10656, 14144, -4576, -858, 45045,
1723 64, 624, -4576, 6864, -3003, 15015,
1725 100, 208, 572, 3432, -12012, 30030, 45045,
1731 5792, 1040, -1287, 135135,
1733 5952, -11648, 9152, -2574, 135135,
1735 -64, -624, 4576, -6864, 3003, 135135,
1741 -8448, 4992, -1144, 225225,
1743 -1440, 4160, -4576, 1716, 225225,
1749 3584, -3328, 1144, 315315,
1757 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7
1758 static const real coeff[] = {
1764 -4480, 1088, 156, 45045,
1766 10736, -224, -4784, 1573, 45045,
1768 1664, -10656, 14144, -4576, -858, 45045,
1770 16, 64, 624, -4576, 6864, -3003, 15015,
1772 56, 100, 208, 572, 3432, -12012, 30030, 45045,
1778 3840, -2944, 468, 135135,
1780 -10704, 5792, 1040, -1287, 135135,
1782 -768, 5952, -11648, 9152, -2574, 135135,
1784 -16, -64, -624, 4576, -6864, 3003, 135135,
1790 1664, 1856, -936, 225225,
1792 6784, -8448, 4992, -1144, 225225,
1794 128, -1440, 4160, -4576, 1716, 225225,
1800 -2048, 1024, -208, 105105,
1802 -1792, 3584, -3328, 1144, 315315,
1808 3072, -2560, 832, 405405,
1816 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8
1817 static const real coeff[] = {
1823 20960, -7888, 4947, 765765,
1825 12480, -76160, 18496, 2652, 765765,
1827 -154048, 182512, -3808, -81328, 26741, 765765,
1829 3232, 28288, -181152, 240448, -77792, -14586, 765765,
1831 96, 272, 1088, 10608, -77792, 116688, -51051, 255255,
1833 588, 952, 1700, 3536, 9724, 58344, -204204, 510510, 765765,
1839 -39840, 1904, 255, 2297295,
1841 52608, 65280, -50048, 7956, 2297295,
1843 103744, -181968, 98464, 17680, -21879, 2297295,
1845 -1344, -13056, 101184, -198016, 155584, -43758, 2297295,
1847 -96, -272, -1088, -10608, 77792, -116688, 51051, 2297295,
1851 -928, -612, 3828825,
1853 64256, -28288, 2856, 3828825,
1855 -126528, 28288, 31552, -15912, 3828825,
1857 -41472, 115328, -143616, 84864, -19448, 3828825,
1859 160, 2176, -24480, 70720, -77792, 29172, 3828825,
1863 -16384, 1088, 5360355,
1865 -2560, 30464, -11560, 5360355,
1867 35840, -34816, 17408, -3536, 1786785,
1869 7168, -30464, 60928, -56576, 19448, 5360355,
1873 26624, -8704, 6891885,
1875 -77824, 34816, -6528, 6891885,
1877 -32256, 52224, -43520, 14144, 6891885,
1881 24576, -4352, 8423415,
1883 45056, -34816, 10880, 8423415,
1887 -28672, 8704, 9954945,
1892 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER"
1894 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(
real) ==
1895 (nC4_ * (nC4_ + 1) * (nC4_ + 5)) / 6,
1896 "Coefficient array size mismatch in C4coeff");
1898 for (
int l = 0; l < nC4_; ++l) {
1899 for (
int j = nC4_ - 1; j >= l; --j) {
1900 int m = nC4_ - j - 1;
1901 _C4x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
static T AngNormalize(T x)
GeodesicLine ArcDirectLine(real lat1, real lon1, real azi1, real a12, unsigned caps=ALL) const
Header for GeographicLib::GeodesicLine class.
GeodesicLine Line(real lat1, real lon1, real azi1, unsigned caps=ALL) const
GeographicLib::Math::real real
static const Geodesic & WGS84()
static bool isfinite(T x)
Mathematical functions needed by GeographicLib.
static void sincosd(T x, T &sinx, T &cosx)
static T AngDiff(T x, T y, T &e)
static void norm(T &x, T &y)
#define GEOGRAPHICLIB_VOLATILE
GeodesicLine DirectLine(real lat1, real lon1, real azi1, real s12, unsigned caps=ALL) const
Header for GeographicLib::Geodesic class.
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
static T atan2d(T y, T x)
static T polyval(int N, const T p[], T x)
Namespace for GeographicLib.
Exception handling for GeographicLib.
GeodesicLine InverseLine(real lat1, real lon1, real lat2, real lon2, unsigned caps=ALL) const
GeodesicLine GenDirectLine(real lat1, real lon1, real azi1, bool arcmode, real s12_a12, unsigned caps=ALL) const
#define GEOGRAPHICLIB_PANIC