Allow appending on a PerlIO::Scalar
[p5sagit/p5-mst-13.2.git] / t / lib / trig.t
index ac34450..4246a47 100755 (executable)
@@ -26,10 +26,11 @@ if ($^O eq 'unicos') { # See lib/Math/Complex.pm and t/lib/complex.t.
 }
 
 sub near ($$;$) {
-    abs($_[0] - $_[1]) < (defined $_[2] ? $_[2] : $eps);
+    my $e = defined $_[2] ? $_[2] : $eps;
+    $_[1] ? (abs($_[0]/$_[1] - 1) < $e) : abs($_[0]) < $e;
 }
 
-print "1..23\n";
+print "1..26\n";
 
 $x = 0.9;
 print 'not ' unless (near(tan($x), sin($x) / cos($x)));
@@ -175,4 +176,25 @@ use Math::Trig ':radial';
     print "ok 23\n";
 }
 
+{
+    use Math::Trig 'great_circle_direction';
+
+    print 'not '
+       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));
+    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);
+
+    print 'not ' unless (near($rad, -0.546644569997376));
+    print "ok 26\n";
+}
+
 # eof