Improve short-distance accuracy of Andoyer inverse#1461
Open
mjacobse wants to merge 1 commit intoboostorg:developfrom
Open
Improve short-distance accuracy of Andoyer inverse#1461mjacobse wants to merge 1 commit intoboostorg:developfrom
mjacobse wants to merge 1 commit intoboostorg:developfrom
Conversation
Use haversine formula instead of law of cosines to avoid numerical loss of precision for close points as suggested in boostorg#1217. This had the side-effect of returning non-zero azimuths for smaller angles than before, which resulted in quite inaccurate non-zero reduced length and geodesic scale values too. To fix this, division by the cosine of the latitudes was changed to be done implicitly within atan2, which together with use of the haversine formula improves accuracy for all result values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use haversine formula instead of law of cosines to avoid numerical loss of precision for close points as suggested in #1217.
This has the side-effect of returning non-zero azimuths for smaller angles than before, which results in quite inaccurate non-zero reduced length and geodesic scale values too. To fix this, division by the cosine of the latitudes is changed to be done implicitly within
atan2, which together with use of the haversine formula improves accuracy for all result values.I planned to add tests for very close points like
{8.81, 53.08}, {8.81000001, 53.08}toinverse_cases.hpp, since Andoyer returns a distance of about 9cm for such examples before this change, which has a very large relative error. Unfortunately the other formulas (especially Thomas) have some issues with examples like that too, so I could not easily get such tests to pass. Suggestions would be welcome.The following plots (generated using a simple test executable and a Python script, see mjacobse@d2930ae) show the errors of the different quantities compared to GeographicLib for many randomly generated pairs of points depending on the order of magnitude of the distance between them (top row absolute error, bottom row relative error. red before these changes, green after):
distance:

azimuth:

reverse_azimuth:

reduced_length:

geodesic_scale:
