### ----------------------------------------------------
### -- Geo::Ellipsoid
### -- Licenses: Artistic-2.0
### -- Authors: Tom Browder <tbrowder@acm.org> (translator Perl 5 to Raku, current maintainer), Jim Gibson (CPAN Perl 5 author, v1.12)
### -- File: t/09-bearing.t
### ----------------------------------------------------
### -- Chunk 1 of 7
# Test Geo::Ellipsoid bearing

use v6;
use Test;

plan 432;

use Geo::Ellipsoid;

# This original Perl 5 test used the following test functions (the
# resulting Perl 6 versions are shown after the fat comma):
#
#   delta_within => is-approx($a, $b, :abs-tol<?>)
#
#  From the Perl 5 test file:
#    use Test::Number::Delta relative => 1e-6;
#  which translates to:
my $rel-tol = 1e-6;

my $e_pos = Geo::Ellipsoid.new(units=>'degrees');
my $e_sym = Geo::Ellipsoid.new(units=>'degrees',bearing_sym=>True);
my ($azp,$azs);

$azp = $e_pos.bearing(-88.000000, 1.000000, -88.000000, 90.000000);
is-approx($azp, 134.482545961512, :abs-tol<0.1>); #delta_within($azp, 134.482545961512, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,-88.000000,90.000000);
is-approx($azs, 134.482545961512, :abs-tol<0.1>); #delta_within($azs, 134.482545961512, 0.1);

$azp = $e_pos.bearing(-88.000000,1.000000,-88.000000,179.000000);
is-approx($azp, 178.999390582928, :abs-tol<0.1>); #delta_within($azp, 178.999390582928, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,-88.000000,179.000000);
is-approx($azs, 178.999390582928, :abs-tol<0.1>); #delta_within($azs, 178.999390582928, 0.1);

#say "DEBUG exit"; exit;

$azp = $e_pos.bearing(-88.000000,1.000000,-88.000000,268.000000);
is-approx($azp, 223.517433140781, :abs-tol<0.1>); #delta_within($azp, 223.517433140781, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,-88.000000,268.000000);
is-approx($azs, -136.482566859219, :abs-tol<0.1>); #delta_within($azs, -136.482566859219, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,0.000000,1.000000);
is-approx($azs, 0, :abs-tol<0.1>); #delta_within($azs, 0, 0.1);

$azp = $e_pos.bearing(-88.000000,1.000000,0.000000,90.000000);
is-approx($azp, 89.011158607559, :abs-tol<0.1>); #delta_within($azp, 89.011158607559, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,0.000000,90.000000);
is-approx($azs, 89.011158607559, :abs-tol<0.1>); #delta_within($azs, 89.011158607559, 0.1);

$azp = $e_pos.bearing(-88.000000,1.000000,0.000000,179.000000);
is-approx($azp, 177.999150742584, :abs-tol<0.1>); #delta_within($azp, 177.999150742584, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,0.000000,179.000000);
is-approx($azs, 177.999150742584, :abs-tol<0.1>); #delta_within($azs, 177.999150742584, 0.1);

$azp = $e_pos.bearing(-88.000000,1.000000,0.000000,268.000000);
is-approx($azp, 266.991287566797, :abs-tol<0.1>); #delta_within($azp, 266.991287566797, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,0.000000,268.000000);
is-approx($azs, -93.0087124332033, :abs-tol<0.1>); #delta_within($azs, -93.0087124332033, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,88.000000,1.000000);
is-approx($azs, 0, :abs-tol<0.1>); #delta_within($azs, 0, 0.1);

$azp = $e_pos.bearing(-88.000000,1.000000,88.000000,90.000000);
is-approx($azp, 44.5248574511054, :abs-tol<0.1>); #delta_within($azp, 44.5248574511054, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,88.000000,90.000000);
is-approx($azs, 44.5248574511054, :abs-tol<0.1>); #delta_within($azs, 44.5248574511054, 0.1);

$azp = $e_pos.bearing(-88.000000,1.000000,88.000000,179.000000);
is-approx($azp, 89.011158607592, :abs-tol<0.1>); #delta_within($azp, 89.011158607592, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,88.000000,179.000000);
is-approx($azs, 89.011158607592, :abs-tol<0.1>); #delta_within($azs, 89.011158607592, 0.1);

$azp = $e_pos.bearing(-88.000000,1.000000,88.000000,268.000000);
is-approx($azp, 313.474906296863, :abs-tol<0.1>); #delta_within($azp, 313.474906296863, 0.1);

$azs = $e_sym.bearing(-88.000000,1.000000,88.000000,268.000000);
is-approx($azs, -46.5250937031367, :abs-tol<0.1>); #delta_within($azs, -46.5250937031367, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,-88.000000,1.000000);
is-approx($azp, 225.517454038488, :abs-tol<0.1>); #delta_within($azp, 225.517454038488, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,-88.000000,1.000000);
is-approx($azs, -134.482545961512, :abs-tol<0.1>); #delta_within($azs, -134.482545961512, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,-88.000000,179.000000);
is-approx($azp, 134.482545961512, :abs-tol<0.1>); #delta_within($azp, 134.482545961512, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,-88.000000,179.000000);
is-approx($azs, 134.482545961512, :abs-tol<0.1>); #delta_within($azs, 134.482545961512, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,-88.000000,268.000000);
is-approx($azp, 178.999390582928, :abs-tol<0.1>); #delta_within($azp, 178.999390582928, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,-88.000000,268.000000);
is-approx($azs, 178.999390582928, :abs-tol<0.1>); #delta_within($azs, 178.999390582928, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,0.000000,1.000000);
is-approx($azp, 270.988841392441, :abs-tol<0.1>); #delta_within($azp, 270.988841392441, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,0.000000,1.000000);
is-approx($azs, -89.011158607559, :abs-tol<0.1>); #delta_within($azs, -89.011158607559, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,0.000000,90.000000);
is-approx($azs, 0, :abs-tol<0.1>); #delta_within($azs, 0, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,0.000000,179.000000);
is-approx($azp, 89.011158607559, :abs-tol<0.1>); #delta_within($azp, 89.011158607559, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,0.000000,179.000000);
is-approx($azs, 89.011158607559, :abs-tol<0.1>); #delta_within($azs, 89.011158607559, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,0.000000,268.000000);
is-approx($azp, 177.999150742584, :abs-tol<0.1>); #delta_within($azp, 177.999150742584, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,0.000000,268.000000);
is-approx($azs, 177.999150742584, :abs-tol<0.1>); #delta_within($azs, 177.999150742584, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,88.000000,1.000000);
is-approx($azp, 315.475142548895, :abs-tol<0.1>); #delta_within($azp, 315.475142548895, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,88.000000,1.000000);
is-approx($azs, -44.5248574511054, :abs-tol<0.1>); #delta_within($azs, -44.5248574511054, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,88.000000,90.000000);
is-approx($azs, 0, :abs-tol<0.1>); #delta_within($azs, 0, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,88.000000,179.000000);
is-approx($azp, 44.5248574511054, :abs-tol<0.1>); #delta_within($azp, 44.5248574511054, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,88.000000,179.000000);
is-approx($azs, 44.5248574511054, :abs-tol<0.1>); #delta_within($azs, 44.5248574511054, 0.1);

$azp = $e_pos.bearing(-88.000000,90.000000,88.000000,268.000000);
is-approx($azp, 89.011158607592, :abs-tol<0.1>); #delta_within($azp, 89.011158607592, 0.1);

$azs = $e_sym.bearing(-88.000000,90.000000,88.000000,268.000000);
is-approx($azs, 89.011158607592, :abs-tol<0.1>); #delta_within($azs, 89.011158607592, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,-88.000000,1.000000);
is-approx($azp, 181.000609417072, :abs-tol<0.1>); #delta_within($azp, 181.000609417072, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,-88.000000,1.000000);
is-approx($azs, -178.999390582928, :abs-tol<0.1>); #delta_within($azs, -178.999390582928, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,-88.000000,90.000000);
is-approx($azp, 225.517454038488, :abs-tol<0.1>); #delta_within($azp, 225.517454038488, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,-88.000000,90.000000);
is-approx($azs, -134.482545961512, :abs-tol<0.1>); #delta_within($azs, -134.482545961512, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,-88.000000,268.000000);
is-approx($azp, 134.482545961512, :abs-tol<0.1>); #delta_within($azp, 134.482545961512, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,-88.000000,268.000000);
is-approx($azs, 134.482545961512, :abs-tol<0.1>); #delta_within($azs, 134.482545961512, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,0.000000,1.000000);
is-approx($azp, 182.000849257416, :abs-tol<0.1>); #delta_within($azp, 182.000849257416, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,0.000000,1.000000);
is-approx($azs, -177.999150742584, :abs-tol<0.1>); #delta_within($azs, -177.999150742584, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,0.000000,90.000000);
is-approx($azp, 270.988841392441, :abs-tol<0.1>); #delta_within($azp, 270.988841392441, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,0.000000,90.000000);
is-approx($azs, -89.011158607559, :abs-tol<0.1>); #delta_within($azs, -89.011158607559, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,0.000000,179.000000);
is-approx($azs, 0, :abs-tol<0.1>); #delta_within($azs, 0, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,0.000000,268.000000);
is-approx($azp, 89.011158607559, :abs-tol<0.1>); #delta_within($azp, 89.011158607559, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,0.000000,268.000000);
is-approx($azs, 89.011158607559, :abs-tol<0.1>); #delta_within($azs, 89.011158607559, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,88.000000,1.000000);
is-approx($azp, 270.988841392408, :abs-tol<0.1>); #delta_within($azp, 270.988841392408, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,88.000000,1.000000);
is-approx($azs, -89.011158607592, :abs-tol<0.1>); #delta_within($azs, -89.011158607592, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,88.000000,90.000000);
is-approx($azp, 315.475142548895, :abs-tol<0.1>); #delta_within($azp, 315.475142548895, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,88.000000,90.000000);
is-approx($azs, -44.5248574511054, :abs-tol<0.1>); #delta_within($azs, -44.5248574511054, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,88.000000,179.000000);
is-approx($azs, 0, :abs-tol<0.1>); #delta_within($azs, 0, 0.1);

$azp = $e_pos.bearing(-88.000000,179.000000,88.000000,268.000000);
is-approx($azp, 44.5248574511054, :abs-tol<0.1>); #delta_within($azp, 44.5248574511054, 0.1);

$azs = $e_sym.bearing(-88.000000,179.000000,88.000000,268.000000);
is-approx($azs, 44.5248574511054, :abs-tol<0.1>); #delta_within($azs, 44.5248574511054, 0.1);

$azp = $e_pos.bearing(-88.000000,268.000000,-88.000000,1.000000);
is-approx($azp, 136.482566859219, :abs-tol<0.1>); #delta_within($azp, 136.482566859219, 0.1);

$azs = $e_sym.bearing(-88.000000,268.000000,-88.000000,1.000000);
is-approx($azs, 136.482566859219, :abs-tol<0.1>); #delta_within($azs, 136.482566859219, 0.1);

$azp = $e_pos.bearing(-88.000000,268.000000,-88.000000,90.000000);
is-approx($azp, 181.000609417072, :abs-tol<0.1>); #delta_within($azp, 181.000609417072, 0.1);

$azs = $e_sym.bearing(-88.000000,268.000000,-88.000000,90.000000);
is-approx($azs, -178.999390582928, :abs-tol<0.1>); #delta_within($azs, -178.999390582928, 0.1);

$azp = $e_pos.bearing(-88.000000,268.000000,-88.000000,179.000000);
is-approx($azp, 225.517454038488, :abs-tol<0.1>); #delta_within($azp, 225.517454038488, 0.1);

$azs = $e_sym.bearing(-88.000000,268.000000,-88.000000,179.000000);
is-approx($azs, -134.482545961512, :abs-tol<0.1>); #delta_within($azs, -134.482545961512, 0.1);

$azp = $e_pos.bearing(-88.000000,268.000000,0.000000,1.000000);
is-approx($azp, 93.0087124332033, :abs-tol<0.1>); #delta_within($azp, 93.0087124332033, 0.1);

$azs = $e_sym.bearing(-88.000000,268.000000,0.000000,1.000000);
is-approx($azs, 93.0087124332033, :abs-tol<0.1>); #delta_within($azs, 93.0087124332033, 0.1);

$azp = $e_pos.bearing(-88.000000,268.000000,0.000000,90.000000);
is-approx($azp, 182.000849257416, :abs-tol<0.1>); #delta_within($azp, 182.000849257416, 0.1);

$azs = $e_sym.bearing(-88.000000,268.000000,0.000000,90.000000);
is-approx($azs, -177.999150742584, :abs-tol<0.1>); #delta_within($azs, -177.999150742584, 0.1);

$azp = $e_pos.bearing(-88.000000,268.000000,0.000000,179.000000);
is-approx($azp, 270.988841392441, :abs-tol<0.1