X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMath%2FTrig.t;h=5b1f12e95c698072d895d7118eff61e450c47b6e;hb=25a47338fa155bc151c8e5863827e694dd2d036d;hp=4246a47c403ce6b9146715d0c573ec418e814066;hpb=b695f709e8a342e35e482b0437eb6cdacdc58b6b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Math/Trig.t b/lib/Math/Trig.t index 4246a47..5b1f12e 100755 --- a/lib/Math/Trig.t +++ b/lib/Math/Trig.t @@ -27,10 +27,11 @@ if ($^O eq 'unicos') { # See lib/Math/Complex.pm and t/lib/complex.t. sub near ($$;$) { my $e = defined $_[2] ? $_[2] : $eps; + print "# near? $_[0] $_[1] $e\n"; $_[1] ? (abs($_[0]/$_[1] - 1) < $e) : abs($_[0]) < $e; } -print "1..26\n"; +print "1..29\n"; $x = 0.9; print 'not ' unless (near(tan($x), sin($x) / cos($x))); @@ -183,18 +184,35 @@ use Math::Trig ':radial'; unless (near(great_circle_direction(0, 0, 0, pi/2), pi)); print "ok 24\n"; - print 'not ' - unless (near(great_circle_direction(0, 0, pi, pi), -pi()/2)); +# Retired test: Relies on atan(0, 0), which is not portable. +# print 'not ' +# unless (near(great_circle_direction(0, 0, pi, pi), -pi()/2)); print "ok 25\n"; - # London to Tokyo. - my @L = (deg2rad(-0.5), deg2rad(90 - 51.3)); - my @T = (deg2rad(139.8),deg2rad(90 - 35.7)); - - my $rad = great_circle_direction(@L, @T); + my @London = (deg2rad( -0.167), deg2rad(90 - 51.3)); + my @Tokyo = (deg2rad( 139.5), deg2rad(90 - 35.7)); + my @Berlin = (deg2rad ( 13.417), deg2rad(90 - 52.533)); + my @Paris = (deg2rad ( 2.333), deg2rad(90 - 48.867)); - print 'not ' unless (near($rad, -0.546644569997376)); + print 'not ' + unless (near(rad2deg(great_circle_direction(@London, @Tokyo)), + 31.791945393073)); + print "ok 26\n"; + print 'not ' + unless (near(rad2deg(great_circle_direction(@Tokyo, @London)), + 336.069766430326)); + print "ok 27\n"; + + print 'not ' + unless (near(rad2deg(great_circle_direction(@Berlin, @Paris)), + 246.800348034667)); + + print "ok 28\n"; + print 'not ' + unless (near(rad2deg(great_circle_direction(@Paris, @Berlin)), + 58.2079877553156)); + print "ok 29\n"; } # eof