Here's the situation:

I need some assistance with converting the following:

Background:

1. In Air Navigation, devices known as Navigational Aids (Navaid) send out radio beams known as Radials ranging from 0 to 359 degrees. Distance from the navaid is also transmitted in nautical miles. (known as DME)

2. The latitude/longitude of the Navaid is a known constant.

The Problem:

I have tried everything I can think of to come up with this:

1. Given a Radial & DME, convert to standard Latitude & Longitude

2. Give a Latitude & Longitude, convert to a Radial & DME

Any assistance is greatly appreciated.

Option Explicit

Private Type tpInfo

ID As String

x As Double

y As Double

End Type

Dim airports(1 To 2) As tpInfo

Private Sub Form_Click()

airports(1).ID = "SJJ"

airports(1).x = 18.336

airports(1).y = 43.825

airports(2).ID = "NAP"

airports(2).x = 14.269

airports(2).y = 40.834

Dim dist As Double

dist = distance(airports(1).y, airports(1).x, airports(2).y, airports(2).x)

MsgBox dist

End Sub

Public Function distance(p1 As Double, t1 As Double, p2 As Double, t2 As Double) As Double

'arccos( Cos[p1]*Cos[p2]*Cos[t2 - t1] + Sin[p1]*Sin[p2] )

Dim x As Double

Dim rp1 As Double

Dim rt1 As Double

Dim rp2 As Double

Dim rt2 As Double

Dim PI As Double

PI = Atn(1) * 4 'calculate pi

rp1 = p1 * PI / 180 'change angles in degrees to radians

rt1 = t1 * PI / 180

rp2 = p2 * PI / 180

rt2 = t2 * PI / 180

'ozo's formula

x = Cos(rp1) * Cos(rp2) * Cos(rt2 - rt1) + Sin(rp1) * Sin(rp2)

'find angle, change back to degrees, and multiply by 69

distance = 69.09398 * Arccos(x) * (180 / PI)

End Function

Private Function Arccos(ByVal x As Double) As Double

'From the VB help - seems to handle -ve angles better

If Abs(x) <> 1 Then

Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)

Else

Arccos = IIf(x = 1, 0, Atn(1) * 4)

End If

End Function