sub infix:<∠> (Real $b1, Real $b2) {
(my $b = ($b2 - $b1 + 720) % 360) > 180 ?? $b - 360 !! $b;
}
for 20, 45,
-45, 45,
-85, 90,
-95, 90,
-45, 125,
-45, 145,
29.4803, -88.6381,
-78.3251, -159.036,
-70099.74233810938, 29840.67437876723,
-165313.6666297357, 33693.9894517456,
1174.8380510598456, -154146.66490124757,
60175.77306795546, 42213.07192354373
-> $b1, $b2 { say "$b1 ∠ $b2 = ", $b1 ∠ $b2 }
Output:
20 ∠ 45 = 25
-45 ∠ 45 = 90
-85 ∠ 90 = 175
-95 ∠ 90 = -175
-45 ∠ 125 = 170
-45 ∠ 145 = -170
29.4803 ∠ -88.6381 = -118.1184
-78.3251 ∠ -159.036 = -80.7109
-70099.74233810938 ∠ 29840.67437876723 = -139.58328312339
-165313.6666297357 ∠ 33693.9894517456 = -72.3439185187
1174.8380510598456 ∠ -154146.66490124757 = -161.5029523074156
60175.77306795546 ∠ 42213.07192354373 = 37.29885558827