From 618e05e99e34cbe2ae357d3095f9fe6df2a90941 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Tue, 23 Jan 2007 02:14:57 +0000 Subject: [PATCH] Upgrade to Math-Complex-1.37. p4raw-id: //depot/perl@29932 --- lib/Math/Complex.pm | 5 ++--- lib/Math/Trig.pm | 4 ++-- lib/Math/Trig.t | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/Math/Complex.pm b/lib/Math/Complex.pm index 110e8b6..e70e99f 100644 --- a/lib/Math/Complex.pm +++ b/lib/Math/Complex.pm @@ -9,11 +9,11 @@ package Math::Complex; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $Inf); -$VERSION = 1.36; +$VERSION = 1.37; BEGIN { unless ($^O eq 'unicosmk') { - my $e = $!; + local $!; # We do want an arithmetic overflow, Inf INF inf Infinity:. undef $Inf unless eval <<'EOE' and $Inf =~ /^inf(?:inity)?$/i; local $SIG{FPE} = sub {die}; @@ -27,7 +27,6 @@ EOE $Inf = $t + "1e99999999999999999999999999999999"; EOE } - $! = $e; # Clear ERANGE. } $Inf = "Inf" if !defined $Inf || !($Inf > 0); # Desperation. } diff --git a/lib/Math/Trig.pm b/lib/Math/Trig.pm index 37b3b75..0ae7233 100644 --- a/lib/Math/Trig.pm +++ b/lib/Math/Trig.pm @@ -189,7 +189,7 @@ sub great_circle_waypoint { my $z = $A * sin($lat0) + $B * sin($lat1); my $theta = atan2($y, $x); - my $phi = atan2($z, sqrt($x*$x + $y*$y)); + my $phi = acos($z); return ($theta, $phi); } @@ -647,7 +647,7 @@ The midpoint between London and Tokyo being my @M = great_circle_midpoint(@L, @T); -or about 68.11N 24.74E, in the Finnish Lapland. +or about 89.16N 68.93E, practically at the North Pole. =head2 CAVEAT FOR GREAT CIRCLE FORMULAS diff --git a/lib/Math/Trig.t b/lib/Math/Trig.t index 65bb796..69b34fc 100755 --- a/lib/Math/Trig.t +++ b/lib/Math/Trig.t @@ -207,37 +207,37 @@ use Math::Trig ':radial'; ok(near($lon, $London[0])); - ok(near($lat, $pip2 - $London[1])); + ok(near($lat, $London[1])); ($lon, $lat) = great_circle_waypoint(@London, @Tokyo, 1.0); ok(near($lon, $Tokyo[0])); - ok(near($lat, $pip2 - $Tokyo[1])); + ok(near($lat, $Tokyo[1])); ($lon, $lat) = great_circle_waypoint(@London, @Tokyo, 0.5); - ok(near($lon, 1.55609593577679)); # 89.1577 E + ok(near($lon, 1.55609593577679)); # 89.16 E - ok(near($lat, 1.20296099733328)); # 68.9246 N + ok(near($lat, 0.36783532946162)); # 68.93 N ($lon, $lat) = great_circle_midpoint(@London, @Tokyo); - ok(near($lon, 1.55609593577679)); # 89.1577 E + ok(near($lon, 1.55609593577679)); # 89.16 E - ok(near($lat, 1.20296099733328)); # 68.9246 N + ok(near($lat, 0.367835329461615)); # 68.93 N ($lon, $lat) = great_circle_waypoint(@London, @Tokyo, 0.25); - ok(near($lon, 0.516073562850837)); # 29.5688 E + ok(near($lon, 0.516073562850837)); # 29.57 E - ok(near($lat, 1.170565013391510)); # 67.0684 N + ok(near($lat, 0.400231313403387)); # 67.07 N ($lon, $lat) = great_circle_waypoint(@London, @Tokyo, 0.75); - ok(near($lon, 2.17494903805952)); # 124.6154 E + ok(near($lon, 2.17494903805952)); # 124.62 E - ok(near($lat, 0.952987032741305)); # 54.6021 N + ok(near($lat, 0.617809294053591)); # 54.60 N use Math::Trig 'great_circle_destination'; -- 2.7.4