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 ))
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 {
159 Math::real Geodesic::GenInverse(real lat1, real lon1, real lat2, real lon2,
160 unsigned outmask, real& s12,
161 real& salp1, real& calp1,
162 real& salp2, real& calp2,
163 real& m12, real& M12, real& M21,
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, domg12 = 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, domg12, 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);
402 if (outmask &
AREA) {
404 real sdomg12 = sin(domg12), cdomg12 = cos(domg12);
405 somg12 = slam12 * cdomg12 - clam12 * sdomg12;
406 comg12 = clam12 * cdomg12 + slam12 * sdomg12;
417 if (outmask &
AREA) {
420 salp0 = salp1 * cbet1,
423 if (calp0 != 0 && salp0 != 0) {
426 ssig1 = sbet1, csig1 = calp1 * cbet1,
427 ssig2 = sbet2, csig2 = calp2 * cbet2,
429 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2),
431 A4 =
Math::sq(_a) * calp0 * salp0 * _e2;
436 B41 = SinCosSeries(
false, ssig1, csig1, Ca, nC4_),
437 B42 = SinCosSeries(
false, ssig2, csig2, Ca, nC4_);
438 S12 = A4 * (B42 - B41);
443 if (!meridian && somg12 > 1) {
444 somg12 = sin(omg12); comg12 = cos(omg12);
449 comg12 > -real(0.7071) &&
450 sbet2 - sbet1 < real(1.75)) {
454 real domg12 = 1 + comg12, dbet1 = 1 + cbet1, dbet2 = 1 + cbet2;
455 alp12 = 2 * atan2( somg12 * ( sbet1 * dbet2 + sbet2 * dbet1 ),
456 domg12 * ( sbet1 * sbet2 + dbet1 * dbet2 ) );
460 salp12 = salp2 * calp1 - calp2 * salp1,
461 calp12 = calp2 * calp1 + salp2 * salp1;
466 if (salp12 == 0 && calp12 < 0) {
467 salp12 = tiny_ * calp1;
470 alp12 = atan2(salp12, calp12);
473 S12 *= swapp * lonsign * latsign;
486 salp1 *= swapp * lonsign; calp1 *= swapp * latsign;
487 salp2 *= swapp * lonsign; calp2 *= swapp * latsign;
493 Math::real Geodesic::GenInverse(real lat1, real lon1, real lat2, real lon2,
495 real& s12, real& azi1, real& azi2,
496 real& m12, real& M12, real& M21,
499 real salp1, calp1, salp2, calp2,
500 a12 = GenInverse(lat1, lon1, lat2, lon2,
501 outmask, s12, salp1, calp1, salp2, calp2,
511 real lat2, real lon2,
512 unsigned caps)
const {
513 real t, salp1, calp1, salp2, calp2,
514 a12 = GenInverse(lat1, lon1, lat2, lon2,
516 0u, t, salp1, calp1, salp2, calp2,
522 GeodesicLine(*
this, lat1, lon1, azi1, salp1, calp1, caps,
true, a12);
525 void Geodesic::Lengths(real eps, real sig12,
526 real ssig1, real csig1, real dn1,
527 real ssig2, real csig2, real dn2,
528 real cbet1, real cbet2,
unsigned outmask,
529 real& s12b, real& m12b, real& m0,
530 real& M12, real& M21,
541 real m0x = 0, J12 = 0, A1 = 0, A2 = 0;
555 real B1 = SinCosSeries(
true, ssig2, csig2, Ca, nC1_) -
556 SinCosSeries(
true, ssig1, csig1, Ca, nC1_);
558 s12b = A1 * (sig12 + B1);
560 real B2 = SinCosSeries(
true, ssig2, csig2, Cb, nC2_) -
561 SinCosSeries(
true, ssig1, csig1, Cb, nC2_);
562 J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
566 for (
int l = 1; l <= nC2_; ++l)
567 Cb[l] = A1 * Ca[l] - A2 * Cb[l];
568 J12 = m0x * sig12 + (SinCosSeries(
true, ssig2, csig2, Cb, nC2_) -
569 SinCosSeries(
true, ssig1, csig1, Cb, nC2_));
576 m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) -
580 real csig12 = csig1 * csig2 + ssig1 * ssig2;
581 real t = _ep2 * (cbet1 - cbet2) * (cbet1 + cbet2) / (dn1 + dn2);
582 M12 = csig12 + (t * ssig2 - csig2 * J12) * ssig1 / dn1;
583 M21 = csig12 - (t * ssig1 - csig1 * J12) * ssig2 / dn2;
587 Math::real Geodesic::Astroid(real x, real y) {
595 if ( !(q == 0 && r <= 0) ) {
604 disc = S * (S + 2 * r3);
611 T3 += T3 < 0 ? -sqrt(disc) : sqrt(disc);
615 u += T + (T != 0 ? r2 / T : 0);
618 real ang = atan2(sqrt(-disc), -(S + r3));
621 u += 2 * r * cos(ang / 3);
626 uv = u < 0 ? q / (v - u) : u + v,
627 w = (uv - q) / (2 * v);
630 k = uv / (sqrt(uv +
Math::sq(w)) + w);
639 Math::real Geodesic::InverseStart(real sbet1, real cbet1, real dn1,
640 real sbet2, real cbet2, real dn2,
641 real lam12, real slam12, real clam12,
642 real& salp1, real& calp1,
644 real& salp2, real& calp2,
655 sbet12 = sbet2 * cbet1 - cbet2 * sbet1,
656 cbet12 = cbet2 * cbet1 + sbet2 * sbet1;
657 real sbet12a = sbet2 * cbet1 + cbet2 * sbet1;
658 bool shortline = cbet12 >= 0 && sbet12 < real(0.5) &&
659 cbet2 * lam12 < real(0.5);
662 real sbetm2 =
Math::sq(sbet1 + sbet2);
665 sbetm2 /= sbetm2 +
Math::sq(cbet1 + cbet2);
666 dnm = sqrt(1 + _ep2 * sbetm2);
667 real omg12 = lam12 / (_f1 * dnm);
668 somg12 = sin(omg12); comg12 = cos(omg12);
670 somg12 = slam12; comg12 = clam12;
673 salp1 = cbet2 * somg12;
674 calp1 = comg12 >= 0 ?
675 sbet12 + cbet2 * sbet1 *
Math::sq(somg12) / (1 + comg12) :
676 sbet12a - cbet2 * sbet1 *
Math::sq(somg12) / (1 - comg12);
680 csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
682 if (shortline && ssig12 < _etol2) {
684 salp2 = cbet1 * somg12;
685 calp2 = sbet12 - cbet1 * sbet2 *
686 (comg12 >= 0 ?
Math::sq(somg12) / (1 + comg12) : 1 - comg12);
689 sig12 = atan2(ssig12, csig12);
690 }
else if (abs(_n) > real(0.1) ||
697 real y, lamscale, betscale;
702 real lam12x = atan2(-slam12, -clam12);
708 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
709 lamscale = _f * cbet1 * A3f(eps) *
Math::pi();
711 betscale = lamscale * cbet1;
713 x = lam12x / lamscale;
714 y = sbet12a / betscale;
718 cbet12a = cbet2 * cbet1 - sbet2 * sbet1,
719 bet12a = atan2(sbet12a, cbet12a);
720 real m12b, m0, dummy;
724 sbet1, -cbet1, dn1, sbet2, cbet2, dn2,
727 x = -1 + m12b / (cbet1 * cbet2 * m0 *
Math::pi());
728 betscale = x < -real(0.01) ? sbet12a / x :
730 lamscale = betscale / cbet1;
731 y = lam12x / lamscale;
734 if (y > -tol1_ && x > -1 - xthresh_) {
738 salp1 = min(real(1), -real(x)); calp1 = - sqrt(1 -
Math::sq(salp1));
740 calp1 = max(real(x > -tol1_ ? 0 : -1), real(x));
778 real k = Astroid(x, y);
780 omg12a = lamscale * ( _f >= 0 ? -x * k/(1 + k) : -y * (1 + k)/k );
781 somg12 = sin(omg12a); comg12 = -cos(omg12a);
783 salp1 = cbet2 * somg12;
784 calp1 = sbet12a - cbet2 * sbet1 *
Math::sq(somg12) / (1 - comg12);
791 salp1 = 1; calp1 = 0;
796 Math::real Geodesic::Lambda12(real sbet1, real cbet1, real dn1,
797 real sbet2, real cbet2, real dn2,
798 real salp1, real calp1,
799 real slam120, real clam120,
800 real& salp2, real& calp2,
802 real& ssig1, real& csig1,
803 real& ssig2, real& csig2,
804 real& eps, real& domg12,
805 bool diffp, real& dlam12,
809 if (sbet1 == 0 && calp1 == 0)
816 salp0 = salp1 * cbet1,
819 real somg1, comg1, somg2, comg2, somg12, comg12, lam12;
822 ssig1 = sbet1; somg1 = salp0 * sbet1;
823 csig1 = comg1 = calp1 * cbet1;
831 salp2 = cbet2 != cbet1 ? salp0 / cbet2 : salp1;
836 calp2 = cbet2 != cbet1 || abs(sbet2) != -sbet1 ?
839 (cbet2 - cbet1) * (cbet1 + cbet2) :
840 (sbet1 - sbet2) * (sbet1 + sbet2))) / cbet2 :
844 ssig2 = sbet2; somg2 = salp0 * sbet2;
845 csig2 = comg2 = calp2 * cbet2;
850 sig12 = atan2(max(real(0), csig1 * ssig2 - ssig1 * csig2),
851 csig1 * csig2 + ssig1 * ssig2);
854 somg12 = max(real(0), comg1 * somg2 - somg1 * comg2);
855 comg12 = comg1 * comg2 + somg1 * somg2;
857 real eta = atan2(somg12 * clam120 - comg12 * slam120,
858 comg12 * clam120 + somg12 * slam120);
861 eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
863 B312 = (SinCosSeries(
true, ssig2, csig2, Ca, nC3_-1) -
864 SinCosSeries(
true, ssig1, csig1, Ca, nC3_-1));
865 domg12 = -_f * A3f(eps) * salp0 * (sig12 + B312);
866 lam12 = eta + domg12;
870 dlam12 = - 2 * _f1 * dn1 / sbet1;
873 Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
875 dummy, dlam12, dummy, dummy, dummy, Ca);
876 dlam12 *= _f1 / (calp2 * cbet2);
888 void Geodesic::C3f(real eps, real c[])
const {
893 for (
int l = 1; l < nC3_; ++l) {
894 int m = nC3_ - l - 1;
902 void Geodesic::C4f(real eps, real c[])
const {
907 for (
int l = 0; l < nC4_; ++l) {
908 int m = nC4_ - l - 1;
942 #if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1 943 static const real coeff[] = {
947 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2 948 static const real coeff[] = {
952 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3 953 static const real coeff[] = {
957 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4 958 static const real coeff[] = {
960 25, 64, 256, 4096, 0, 16384,
963 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER" 965 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(real) == nA1_/2 + 2,
966 "Coefficient array size mismatch in A1m1f");
969 return (t + eps) / (1 - eps);
973 void Geodesic::C1f(real eps, real c[]) {
975 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3 976 static const real coeff[] = {
984 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4 985 static const real coeff[] = {
995 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5 996 static const real coeff[] = {
1008 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6 1009 static const real coeff[] = {
1023 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7 1024 static const real coeff[] = {
1026 19, -64, 384, -1024, 2048,
1040 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8 1041 static const real coeff[] = {
1043 19, -64, 384, -1024, 2048,
1045 7, -18, 128, -256, 4096,
1049 -11, 96, -160, 16384,
1060 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER" 1062 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(real) ==
1063 (nC1_*nC1_ + 7*nC1_ - 2*(nC1_/2)) / 4,
1064 "Coefficient array size mismatch in C1f");
1069 for (
int l = 1; l <= nC1_; ++l) {
1070 int m = (nC1_ - l) / 2;
1071 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1079 void Geodesic::C1pf(real eps, real c[]) {
1081 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3 1082 static const real coeff[] = {
1090 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4 1091 static const real coeff[] = {
1101 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5 1102 static const real coeff[] = {
1104 205, -432, 768, 1536,
1114 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6 1115 static const real coeff[] = {
1117 205, -432, 768, 1536,
1119 4005, -4736, 3840, 12288,
1129 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7 1130 static const real coeff[] = {
1132 -4879, 9840, -20736, 36864, 73728,
1134 4005, -4736, 3840, 12288,
1136 8703, -7200, 3712, 12288,
1140 -141115, 41604, 92160,
1146 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8 1147 static const real coeff[] = {
1149 -4879, 9840, -20736, 36864, 73728,
1151 -86171, 120150, -142080, 115200, 368640,
1153 8703, -7200, 3712, 12288,
1155 1082857, -688608, 258720, 737280,
1157 -141115, 41604, 92160,
1159 -2200311, 533134, 860160,
1163 109167851, 82575360,
1166 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER" 1168 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(real) ==
1169 (nC1p_*nC1p_ + 7*nC1p_ - 2*(nC1p_/2)) / 4,
1170 "Coefficient array size mismatch in C1pf");
1175 for (
int l = 1; l <= nC1p_; ++l) {
1176 int m = (nC1p_ - l) / 2;
1177 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1187 #if GEOGRAPHICLIB_GEODESIC_ORDER/2 == 1 1188 static const real coeff[] = {
1192 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 2 1193 static const real coeff[] = {
1197 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 3 1198 static const real coeff[] = {
1200 -11, -28, -192, 0, 256,
1202 #elif GEOGRAPHICLIB_GEODESIC_ORDER/2 == 4 1203 static const real coeff[] = {
1205 -375, -704, -1792, -12288, 0, 16384,
1208 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER" 1210 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(real) == nA2_/2 + 2,
1211 "Coefficient array size mismatch in A2m1f");
1214 return (t - eps) / (1 + eps);
1218 void Geodesic::C2f(real eps, real c[]) {
1220 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3 1221 static const real coeff[] = {
1229 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4 1230 static const real coeff[] = {
1240 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5 1241 static const real coeff[] = {
1253 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6 1254 static const real coeff[] = {
1268 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7 1269 static const real coeff[] = {
1271 41, 64, 128, 1024, 2048,
1285 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8 1286 static const real coeff[] = {
1288 41, 64, 128, 1024, 2048,
1290 47, 70, 128, 768, 4096,
1294 133, 224, 1120, 16384,
1305 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER" 1307 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(real) ==
1308 (nC2_*nC2_ + 7*nC2_ - 2*(nC2_/2)) / 4,
1309 "Coefficient array size mismatch in C2f");
1314 for (
int l = 1; l <= nC2_; ++l) {
1315 int m = (nC2_ - l) / 2;
1316 c[l] = d *
Math::polyval(m, coeff + o, eps2) / coeff[o + m + 1];
1324 void Geodesic::A3coeff() {
1326 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3 1327 static const real coeff[] = {
1335 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4 1336 static const real coeff[] = {
1346 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5 1347 static const real coeff[] = {
1359 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6 1360 static const real coeff[] = {
1374 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7 1375 static const real coeff[] = {
1391 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8 1392 static const real coeff[] = {
1400 -5, -20, -4, -6, 128,
1411 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER" 1413 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(real) ==
1414 (nA3_*nA3_ + 7*nA3_ - 2*(nA3_/2)) / 4,
1415 "Coefficient array size mismatch in A3f");
1417 for (
int j = nA3_ - 1; j >= 0; --j) {
1418 int m = min(nA3_ - j - 1, j);
1419 _A3x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1426 void Geodesic::C3coeff() {
1428 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3 1429 static const real coeff[] = {
1437 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4 1438 static const real coeff[] = {
1454 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5 1455 static const real coeff[] = {
1477 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6 1478 static const real coeff[] = {
1510 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7 1511 static const real coeff[] = {
1555 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8 1556 static const real coeff[] = {
1590 10, -6, -10, 9, 384,
1600 -7, 20, -28, 14, 1024,
1615 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER" 1617 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(real) ==
1618 ((nC3_-1)*(nC3_*nC3_ + 7*nC3_ - 2*(nC3_/2)))/8,
1619 "Coefficient array size mismatch in C3coeff");
1621 for (
int l = 1; l < nC3_; ++l) {
1622 for (
int j = nC3_ - 1; j >= l; --j) {
1623 int m = min(nC3_ - j - 1, j);
1624 _C3x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
1631 void Geodesic::C4coeff() {
1633 #if GEOGRAPHICLIB_GEODESIC_ORDER == 3 1634 static const real coeff[] = {
1648 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 4 1649 static const real coeff[] = {
1657 4, 24, -84, 210, 315,
1671 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 5 1672 static const real coeff[] = {
1678 1088, -352, -66, 3465,
1680 48, -352, 528, -231, 1155,
1682 16, 44, 264, -924, 2310, 3465,
1688 -896, 704, -198, 10395,
1690 -48, 352, -528, 231, 10395,
1696 320, -352, 132, 17325,
1704 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 6 1705 static const real coeff[] = {
1711 -224, -4784, 1573, 45045,
1713 -10656, 14144, -4576, -858, 45045,
1715 64, 624, -4576, 6864, -3003, 15015,
1717 100, 208, 572, 3432, -12012, 30030, 45045,
1723 5792, 1040, -1287, 135135,
1725 5952, -11648, 9152, -2574, 135135,
1727 -64, -624, 4576, -6864, 3003, 135135,
1733 -8448, 4992, -1144, 225225,
1735 -1440, 4160, -4576, 1716, 225225,
1741 3584, -3328, 1144, 315315,
1749 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 7 1750 static const real coeff[] = {
1756 -4480, 1088, 156, 45045,
1758 10736, -224, -4784, 1573, 45045,
1760 1664, -10656, 14144, -4576, -858, 45045,
1762 16, 64, 624, -4576, 6864, -3003, 15015,
1764 56, 100, 208, 572, 3432, -12012, 30030, 45045,
1770 3840, -2944, 468, 135135,
1772 -10704, 5792, 1040, -1287, 135135,
1774 -768, 5952, -11648, 9152, -2574, 135135,
1776 -16, -64, -624, 4576, -6864, 3003, 135135,
1782 1664, 1856, -936, 225225,
1784 6784, -8448, 4992, -1144, 225225,
1786 128, -1440, 4160, -4576, 1716, 225225,
1792 -2048, 1024, -208, 105105,
1794 -1792, 3584, -3328, 1144, 315315,
1800 3072, -2560, 832, 405405,
1808 #elif GEOGRAPHICLIB_GEODESIC_ORDER == 8 1809 static const real coeff[] = {
1815 20960, -7888, 4947, 765765,
1817 12480, -76160, 18496, 2652, 765765,
1819 -154048, 182512, -3808, -81328, 26741, 765765,
1821 3232, 28288, -181152, 240448, -77792, -14586, 765765,
1823 96, 272, 1088, 10608, -77792, 116688, -51051, 255255,
1825 588, 952, 1700, 3536, 9724, 58344, -204204, 510510, 765765,
1831 -39840, 1904, 255, 2297295,
1833 52608, 65280, -50048, 7956, 2297295,
1835 103744, -181968, 98464, 17680, -21879, 2297295,
1837 -1344, -13056, 101184, -198016, 155584, -43758, 2297295,
1839 -96, -272, -1088, -10608, 77792, -116688, 51051, 2297295,
1843 -928, -612, 3828825,
1845 64256, -28288, 2856, 3828825,
1847 -126528, 28288, 31552, -15912, 3828825,
1849 -41472, 115328, -143616, 84864, -19448, 3828825,
1851 160, 2176, -24480, 70720, -77792, 29172, 3828825,
1855 -16384, 1088, 5360355,
1857 -2560, 30464, -11560, 5360355,
1859 35840, -34816, 17408, -3536, 1786785,
1861 7168, -30464, 60928, -56576, 19448, 5360355,
1865 26624, -8704, 6891885,
1867 -77824, 34816, -6528, 6891885,
1869 -32256, 52224, -43520, 14144, 6891885,
1873 24576, -4352, 8423415,
1875 45056, -34816, 10880, 8423415,
1879 -28672, 8704, 9954945,
1884 #error "Bad value for GEOGRAPHICLIB_GEODESIC_ORDER" 1886 GEOGRAPHICLIB_STATIC_ASSERT(
sizeof(coeff) /
sizeof(real) ==
1887 (nC4_ * (nC4_ + 1) * (nC4_ + 5)) / 6,
1888 "Coefficient array size mismatch in C4coeff");
1890 for (
int l = 0; l < nC4_; ++l) {
1891 for (
int j = nC4_ - 1; j >= l; --j) {
1892 int m = nC4_ - j - 1;
1893 _C4x[k++] =
Math::polyval(m, coeff + o, _n) / coeff[o + m + 1];
static T AngNormalize(T x)
Header for GeographicLib::GeodesicLine class.
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 bool isfinite(T x)
GeodesicLine Line(real lat1, real lon1, real azi1, unsigned caps=ALL) const
static const Geodesic & WGS84()
Mathematical functions needed by GeographicLib.
GeodesicLine InverseLine(real lat1, real lon1, real lat2, real lon2, unsigned caps=ALL) const
static T AngDiff(T x, T y, T &e)
static void norm(T &x, T &y)
#define GEOGRAPHICLIB_VOLATILE
static T atan2d(T y, T x)
Header for GeographicLib::Geodesic class.
friend class GeodesicLine
GeodesicLine ArcDirectLine(real lat1, real lon1, real azi1, real a12, unsigned caps=ALL) const
static T polyval(int N, const T p[], T x)
GeodesicLine DirectLine(real lat1, real lon1, real azi1, real s12, unsigned caps=ALL) const
Namespace for GeographicLib.
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
Exception handling for GeographicLib.
static void sincosd(T x, T &sinx, T &cosx)
#define GEOGRAPHICLIB_PANIC
GeodesicLine GenDirectLine(real lat1, real lon1, real azi1, bool arcmode, real s12_a12, unsigned caps=ALL) const