From 865abb9cb54ef7cee0f30a2d771cf7fcc7db8c90 Mon Sep 17 00:00:00 2001 From: minima Date: Thu, 26 Jan 2006 18:08:22 +0000 Subject: [PATCH] fix divide by zero error --- Changes | 3 +++ perl/DXBearing.pm | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 37e64c16..8f0e14c0 100644 --- 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 + from the fronts of comments to fix LoTW dupes. 18Jan06======================================================================= diff --git a/perl/DXBearing.pm b/perl/DXBearing.pm index e7736f8a..e0e9910f 100644 --- a/perl/DXBearing.pm +++ b/perl/DXBearing.pm @@ -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; -- 2.43.0