geosphere icon indicating copy to clipboard operation
geosphere copied to clipboard

Fixing out of domaine acos() in alongTrackDistance()

Open clementviolet opened this issue 3 years ago • 0 comments

Hi !

In some rare case, like those reported by #3, https://github.com/rspatial/geosphere/blob/0a775039177646d093edc23c709267ffc7094d76/R/alongTrack.R#L28 The angle in the acos(cos(dp) / cos(xtr)) function can be slightly lower than -1 or higher than +1 due to due to the rounding and machine precision. I added this quick (and maybe a bit dirty) fix to ensure that the angle stays within the domain of the arc-cosine function.

clementviolet avatar Feb 22 '22 17:02 clementviolet