diff options
| author | Charles Karney <charles@karney.com> | 2021-03-13 09:28:00 -0500 |
|---|---|---|
| committer | Charles Karney <charles@karney.com> | 2021-03-13 09:28:00 -0500 |
| commit | eb881d2957d426dd2d43bd3a6a7fe77121cf71ea (patch) | |
| tree | 45895d59acd433434b4ba0b546b31fe5abc5ed42 /src/geodesic.c | |
| parent | 56dce02c707f0fe560f2c4cf5226520746950972 (diff) | |
| download | PROJ-eb881d2957d426dd2d43bd3a6a7fe77121cf71ea.tar.gz PROJ-eb881d2957d426dd2d43bd3a6a7fe77121cf71ea.zip | |
Update geodesic routines from GeographicLib 1.52
Be more aggressive in preventing negative s12 and m12 for short lines.
Initialize reference argument to remquo.
Diffstat (limited to 'src/geodesic.c')
| -rw-r--r-- | src/geodesic.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/geodesic.c b/src/geodesic.c index 53ec9ed6..d5b22ac6 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -18,7 +18,7 @@ * * See the comments in geodesic.h for documentation. * - * Copyright (c) Charles Karney (2012-2020) <charles@karney.com> and licensed + * Copyright (c) Charles Karney (2012-2021) <charles@karney.com> and licensed * under the MIT/X11 License. For more information, see * https://geographiclib.sourceforge.io/ */ @@ -164,7 +164,7 @@ static real AngRound(real x) { static void sincosdx(real x, real* sinx, real* cosx) { /* In order to minimize round-off errors, this function exactly reduces * the argument to the range [-45, 45] before converting it to radians. */ - real r, s, c; int q; + real r, s, c; int q = 0; r = remquo(x, (real)(90), &q); /* now abs(r) <= 45 */ r *= degree; @@ -797,7 +797,9 @@ static real geod_geninverse_int(const struct geod_geodesic* g, * not a shortest path. */ if (sig12 < 1 || m12x >= 0) { /* Need at least 2, to handle 90 0 90 180 */ - if (sig12 < 3 * tiny) + if (sig12 < 3 * tiny || + // Prevent negative s12 or m12 for short lines + (sig12 < tol0 && (s12x < 0 || m12x < 0))) sig12 = m12x = s12x = 0; m12x *= g->b; s12x *= g->b; @@ -868,7 +870,6 @@ static real geod_geninverse_int(const struct geod_geodesic* g, slam12, clam12, &salp2, &calp2, &sig12, &ssig1, &csig1, &ssig2, &csig2, &eps, &domg12, numit < maxit1, &dv, Ca); - /* 2 * tol0 is approximately 1 ulp for a number in [0, pi]. */ /* Reversed test to allow escape with NaNs */ if (tripb || !(fabs(v) >= (tripn ? 8 : 1) * tol0)) break; /* Update bracketing values */ |
