Angle difference between two bearings: Difference between revisions

(adding Common Lisp example)
Line 32:
* 60175.77306795546 and 42213.07192354373
<br><br>
 
=={{header|360 Assembly}}==
{{trans|Rexx}}
<lang 360asm>* Angle difference between two bearings - 06/06/2018
ANGLEDBB CSECT
USING ANGLEDBB,R13 base register
B 72(R15) skip savearea
DC 17F'0' savearea
SAVE (14,12) save previous context
ST R13,4(R15) link backward
ST R15,8(R13) link forward
LR R13,R15 set addressability
LA R10,T-4 @t
LA R6,1 i=1
DO WHILE=(C,R6,LE,N) do i=1 to n
LA R10,4(R10) next @t
L R7,0(R10) a=t(i,1)
LA R10,4(R10) next @t
L R8,0(R10) b=t(i,2)
LR R4,R8 b
SR R4,R7 b-a
SRDA R4,32 ~
D R4,=F'3600000' /360
A R4,=F'5400000' +540
SRDA R4,32 ~
D R4,=F'3600000' /360
S R4,=F'1800000' x=((((b-a)//360)+540)//360)-180
XDECO R7,XDEC edit a
MVC PG(8),XDEC output a
MVC PG+9(4),XDEC+8 output a decimals
XDECO R8,XDEC edit b
MVC PG+14(8),XDEC output b
MVC PG+23(4),XDEC+8 output b decimals
XDECO R4,XDEC edit x
MVC PG+28(8),XDEC output x
MVC PG+37(4),XDEC+8 output x decimals
XPRNT PG,L'PG print
LA R6,1(R6) i++
ENDDO , enddo i
L R13,4(0,R13) restore previous savearea pointer
RETURN (14,12),RC=0 restore registers from calling sav
N DC F'8' number of pairs
T DC F'200000',F'450000',F'-450000',F'450000'
DC F'-850000',F'900000',F'-950000',F'900000'
DC F'-450000',F'1250000',F'450000',F'1450000'
DC F'294803',F'-886361',F'-783251',F'-1590360'
PG DC CL80'12345678.1234 12345678.1234 12345678.1234'
XDEC DS CL12 temp
YREGS
END ANGLEDBB</lang>
{{out}}
<pre>
20.0000 45.0000 25.0000
-45.0000 45.0000 90.0000
-85.0000 90.0000 175.0000
-95.0000 90.0000 -175.0000
-45.0000 125.0000 170.0000
45.0000 145.0000 100.0000
29.4803 -88.6361 -118.1164
-78.3251 -159.0360 -80.7109
</pre>
 
 
=={{header|AWK}}==
Line 86 ⟶ 148:
60175.77 42213.07 37.30
</pre>
 
=={{header|APL}}==
Returns an angle in (-180,180]; so two opposite bearings have a difference of 180 degrees, which is more natural than -180 degrees.
1,392

edits