diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-05-28 19:18:53 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-05-28 19:18:53 +0200 |
commit | 2dfdc09969b8c32887cb45b6f7ff286227ddfd27 (patch) | |
tree | 6203b051ce472fb9c740934bd63ab38a4af4d8e7 | |
parent | 090788ca04d1620c258d3a1e9053b907e87ec3c1 (diff) |
use numerical more stable distance formula
-rw-r--r-- | src/Panorama.cxx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 32e14f4..8bab3e4 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -413,8 +413,11 @@ Panorama::update_coordinates() { double Panorama::distance(double phi, double lam) { - return acos(sin(view_phi) * sin(phi) + - cos(view_phi) * cos(phi) * cos(view_lam - lam)); + double d_lam = view_lam - lam; + + return atan2(sqrt(pow(cos(phi) * sin(d_lam), 2.0) + + pow(cos(view_phi) * sin(phi) - sin(view_phi) * cos(phi) * cos(d_lam), 2.0)), + sin(view_phi) * sin(phi) + cos(view_phi) * cos(phi) * cos(d_lam)); } double @@ -428,7 +431,6 @@ Panorama::alpha(const Hill *m) { return fmod(atan2(sin_alph, cos_alph) + 2.0 * pi_d, 2.0 * pi_d); } - double Panorama::nick(const Hill *m) { double b, c; |