Skip to content

Prevent overshooting cosine in calculation of CachingDms

Toni Schriber requested to merge escriban/kstars:haversine into master

Sometimes the target field of CCD-module was not updated, because the distance to the nearest star was NAN. The reason was the possible, random overshooting of the cosine in the CachingDms-variables in SkyPoint::angularDistanceTo(), which leads to a faulty, negative haversine. A simple std::fmin() prevents any cosine larger than 1. The reason for this was found in calculations of sine/cosine in CachingDms: The use of the trigonometric sum and difference formulas provokes accuracy errors (FPE) with small angles (e.g. cos0 > 1!). In this small angle case (x < 1°) sine and cosine are calculated with the well known and robust small angle approximation formulas.

Edited by Toni Schriber

Merge request reports

Loading