$regfile = "m128def.dat"
$crystal = 16000000

Dim A1 As Double , A2 As Double , A3 As Double , A4 As Double
Dim B1 As Double , B2 As Double , B3 As Double , B4 As Double
Dim B5 As Double , B6 As Double , B7 As Double , B8 As Double
Dim B9 As Double , B10 As Double , B11 As Double , B12 As Double
Dim B13 As Double
Dim D1 As Double , D3 As Double
Dim E1 As Double , E2 As Double , E3 As Double , E4 As Double
Dim E5 As Double , E6 As Double , E7 As Double , E8 As Double
Dim E9 As Double , E10 As Double , E11 As Double , E12 As Double
Dim F1 As Double
Dim Pi As Double
Dim U As String * 8 , V As Single
Dim W As String * 8
Dim Z As String * 8 , Y As Single
Dim X As String * 8

Pi = 3.141592654

Initlcd
Cursor Off
Cls

'Koordinate 1
A1 = 53.51319
A2 = 7.54224

'Koordinate 2
A3 = 53.50206
A4 = 7.57606

D1 = Deg2rad(a1)
D3 = Deg2rad(a3)

F1 = A2 - A4
If F1 >= 0 Then
F1 = 360
Else
F1 = 0
End If

'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'Distanzberechnung:

'Grundformel zur Distanzberechnung zwischen zwei Koordinaten:
'6371,229*ARCCOS(SIN(A1*PI/180)*SIN(A3*PI/180)+COS(A1*PI/180)*COS(A3*PI/180)*COS((A2-A4)*PI/180))

'6371,229*ARCCOS(SIN( B1 )*SIN( B2 )+COS( B1 )*COS( B2 )*COS( B3 ))
'6371,229*ARCCOS( B4 * B5 + B6 * B7 * B8 )
'6371,229*ARCCOS( B9 + B10 )
'6371,229*ARCCOS( B11 )

B1 = Deg2rad(a1)
B2 = Deg2rad(a3)
B3 = A2 - A4
B3 = Deg2rad(b3)
B4 = Sin(b1)
B5 = Sin(b2)
B6 = Cos(b1)
B7 = Cos(b2)
B8 = Cos(b3)
B9 = B4 * B5
B10 = B6 * B7
B10 = B10 * B8
B11 = B10 + B9
B12 = Acos(b11)
B13 = 6371.229 * B12

'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'Winkelberechnung:

'Grundformel zur Winkelberechnung zwischen zwei Koordinaten:
'ABS(ARCCOS(SIN(D3)/SIN(ARCCOS(B9))/COS(D1)-TAN(D1)/TAN(ARCCOS(B9)))*180/PI-F1)

'ABS(ARCCOS( E1 /SIN( E2 )/ E3 - E4 /TAN( E2 ))* E5 -F1)
'ABS(ARCCOS( E1 / E6 / E3 - E4 / E7 )* E5 -F1)
'ABS(ARCCOS( E8 - E9 )* E5 -F1)
'ABS(ARCCOS( E10 )* E5 -F1)
'ABS( E11 * E5 -F1)
'ABS( E11 )

E1 = Sin(d3)
E2 = Acos(b11)
E3 = Cos(d1)
E4 = Tan(d1)
E2 = Acos(b11)
E5 = 180 / Pi
E6 = Sin(e2)
E7 = Tan(e2)
E8 = E1 / E6
E8 = E8 / E3
E9 = E4 / E7
E10 = E8 - E9
E11 = Acos(e10)
E11 = E11 * E5
E11 = E11 - F1
E12 = Abs(e11)
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

U = Str(e12)
V = Val(u)
W = Fusing(v , "#.#")

Z = Str(b13)
Y = Val(z)
X = Fusing(y , "#.####")

Locate 1 , 1
Lcd "K1: "

Locate 2 , 1
Lcd "K2: "

Locate 3 , 1
Lcd "Distanz: " ; X ; " Km"

Locate 4 , 1
Lcd "Winkel : " ; W ; " Grad"

Do
nop
Loop

End