Question VTOL info? (specifically direction)

dmurley

New member
Joined
Dec 11, 2017
Messages
37
Reaction score
0
Points
0
Location
Hill country (near San Antonio
As I approach a VTOL pad I would like to be able to obtain information (via Lua) on the pad's bearing and distance.

Distance is not a problem: range = oapi.get_navrange(hNav)

I don't see anything that will give me a bearing. Am I missing something?

Thanks.
 

dgatsoulis

ele2png user
Joined
Dec 2, 2009
Messages
1,779
Reaction score
27
Points
63
Location
Sparta
One way to do it is to get the pad's global position with oapi.get_navpos, convert to equatorial coords with oapi.global_to_equ and calculate the target's bearing relative to your ship's equ coordinates.

Code:
θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )
where	φ1,λ1 is the start point, φ2,λ2 the end point (Δλ is the difference in longitude)

Several useful long/lat calculations here.

I think that there must be a more elegant way to do this, but the method above does work.
 
Top