Angle difference between two bearings: Difference between revisions

Added APL entry.
No edit summary
(Added APL entry.)
Line 85:
1174.84 -154146.66 -161.50
60175.77 42213.07 37.30
</pre>
=={{header|APL}}==
Returns an angle in (-180,180]; so two opposite bearings are have a difference of 180 degrees, which is more natural than -180 degrees.
<lang APL>[0] D←B1 DIFF B2
[1] D←180+¯360|180+B2-B1
</lang>
{{out}}
<pre> 'B1' 'B2' 'DIFFERENCE'⍪(⊂'¯¯¯¯¯¯¯¯¯¯')⍪(⊃B),DIFF/¨B
B1 B2 DIFFERENCE
¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯
20 45 25
¯45 45 90
¯85 90 175
¯95 90 ¯175
¯45 125 170
¯45 145 ¯170
29.48 ¯88.64 ¯118.12
¯78.33 ¯159.04 ¯80.71
¯70099.74 29840.67 ¯139.59
¯165313.67 3369.99 ¯156.34
1174.84 ¯154146.66 ¯161.5
60175.77 42213.07 37.3
 
270 DIFF 90.01
¯179.99
270 DIFF 90
180
</pre>
 
Anonymous user