fix divide by zero error
authorminima <minima>
Thu, 26 Jan 2006 18:08:22 +0000 (18:08 +0000)
committerminima <minima>
Thu, 26 Jan 2006 18:08:22 +0000 (18:08 +0000)
Changes
perl/DXBearing.pm

diff --git a/Changes b/Changes
index 37e64c1638183ad1bf7b7eb41a2bb0738ce8f9cf..8f0e14c067b84b4190f10968dbb9b22830653246 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+26Jan06=======================================================================
+1. Fix divide by 0 error in DXBearing (how come this has taken so long to
+appear?).
 22Jan06=======================================================================
 1. Remove +<prefix> from the fronts of comments to fix LoTW dupes.
 18Jan06=======================================================================
index e7736f8a138d64a367865bce605631389f96f861..e0e9910f95ca4cb89832e15f8976f9f139d04b83 100644 (file)
@@ -95,12 +95,12 @@ sub bdist
        my $e = dr(shift);
        return (0, 0) if $hn == $n && $he == $e;
        my $co = cos($he-$e)*cos($hn)*cos($n)+sin($hn)*sin($n);
-       my $ca = atan(abs(sqrt(1-$co*$co)/$co));
+       my $ca = $co ? atan(abs(sqrt(1-$co*$co)/$co)) : $pi;
        $ca = $pi-$ca if $co < 0;
        my $dx = 6367*$ca;
        my $si = sin($e-$he)*cos($n)*cos($hn);
        $co = sin($n)-sin($hn)*cos($ca);
-       my $az = atan(abs($si/$co));
+       my $az = $co ? atan(abs($si/$co)) : $pi;
        $az = $pi - $az if $co < 0;
        $az = -$az if $si < 0;
        $az = $az+2*$pi if $az < 0;