Go Back   Orbiter-Forum > Orbiter Addons > Orbiter Lua Scripting
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter Lua Scripting Find support, share snippets and general discussion around using the Lua engine in Orbiter.

Thread Tools
Old 08-10-2019, 09:55 PM   #1
Default VTOL info? (specifically direction)

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?

dmurley is offline   Reply With Quote
Old 08-10-2019, 11:44 PM   #2
ele2png user
dgatsoulis's Avatar

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.

θ = 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.
dgatsoulis is online now   Reply With Quote

  Orbiter-Forum > Orbiter Addons > Orbiter Lua Scripting

Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump

All times are GMT. The time now is 05:19 PM.

Quick Links Need Help?

About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.