Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc.

Reply
 
Thread Tools
Old 10-22-2017, 12:34 PM   #1
JMW
Aspiring Addon Developer
 
JMW's Avatar
Default Distance - closer or further away

Hi
Can anyone help with a simple function to determine whether a vessel is getting closer or further away from a base...........
(Must work even if out of range of base signal)
Thankee.
JMW is offline   Reply With Quote
Old 10-22-2017, 12:45 PM   #2
Notebook
Donator
 
Notebook's Avatar


Default



N.
Notebook is offline   Reply With Quote
Thanked by:
Old 10-22-2017, 12:52 PM   #3
JMW
Aspiring Addon Developer
 
JMW's Avatar
Default

Is that a hint....?
JMW is offline   Reply With Quote
Old 10-22-2017, 01:07 PM   #4
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

In Royal Navy lingo, does the term "rate along" tell you some hint?
Urwumpe is online now   Reply With Quote
Old 10-22-2017, 01:13 PM   #5
JMW
Aspiring Addon Developer
 
JMW's Avatar
Default

Er, knot really as I was never in the Navy.........
JMW is offline   Reply With Quote
Old 10-22-2017, 01:20 PM   #6
Notebook
Donator
 
Notebook's Avatar


Default

Quote:
Originally Posted by JMW View Post
 Is that a hint....?
Not in the slightest, I wouldn't know where to start with your question. Just this came to mind...

N.
Notebook is offline   Reply With Quote
Old 10-22-2017, 01:30 PM   #7
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by JMW View Post
 Er, knot really as I was never in the Navy.........
Range rate? Rate of change of range over time?
Urwumpe is online now   Reply With Quote
Old 10-22-2017, 01:33 PM   #8
JMW
Aspiring Addon Developer
 
JMW's Avatar
Default

Aha!
Let me work on that (don't hold your breath though!)
Thanks Urwumpe
JMW is offline   Reply With Quote
Old 10-22-2017, 01:43 PM   #9
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by JMW View Post
 Aha!
Let me work on that (don't hold your breath though!)
Thanks Urwumpe
Remember, what you use for calculating great circle distance can also be used for calculating great circle range rate.
Urwumpe is online now   Reply With Quote
Old 10-22-2017, 04:18 PM   #10
paddy
Orbinaut
Default

The map in my craft works, so i would just switch on that "function" and it would tell me the distance !!!! (...... I'll get my coat)
paddy is offline   Reply With Quote
Old 10-23-2017, 12:22 PM   #11
martins
Orbiter Founder
Default

Quote:
Originally Posted by JMW View Post
 Hi
Can anyone help with a simple function to determine whether a vessel is getting closer or further away from a base...........
(Must work even if out of range of base signal)
Thankee.
For a simple calculation between two points in space this is trivial:
  • get the relative velocity between ship and target (there is an API function for that)
  • project the relative velocity vector onto the line connecting ship and target
  • Check if the projected velocity points towards or away from the target
For navigation across the surface of a sphere, things like computation of heading towards a target are more complicated. To calculate the closing velocity, you would need to calculate the great circle connecting ship and target and then project the relative velocity onto the tangent of that great circle at the current ship position. However, for answering your binary question the simple cartesian version should still be valid.
martins is offline   Reply With Quote
Thanked by:
Old 10-23-2017, 01:52 PM   #12
jedidia
shoemaker without legs
 
jedidia's Avatar
Default

The approach for the mathematically lazy: Measure distance, store it, next frame see if distance increased or not...
jedidia is offline   Reply With Quote
Thanked by:
Old 10-23-2017, 09:32 PM   #13
kuddel
Donator
Default

Hihi, even in Lua it's easy
See here
...if the RangeRate is negative, you are getting closer, if it is positive, you are ging away.
Or was it the other way around?

Last edited by kuddel; 10-23-2017 at 09:36 PM.
kuddel is offline   Reply With Quote
Thanked by:
Old 10-30-2017, 02:12 PM   #14
JMW
Aspiring Addon Developer
 
JMW's Avatar
Default

Quote:
Originally Posted by jedidia View Post
 The approach for the mathematically lazy: Measure distance, store it, next frame see if distance increased or not...
Can you believe I'm still struggling with this !

What's the best way to do it?
My problem (so far) is how to store without being overwritten by following frame........
JMW is offline   Reply With Quote
Old 08-07-2018, 11:31 AM   #15
JMW
Aspiring Addon Developer
 
JMW's Avatar
Default

Quote:
Originally Posted by martins View Post
  I knew I gave the same answer before, in response to a question by ... you! Any progress between then and now?
Apologies martins, I'd forgotten about this thread.
That brain of yours is why you've got to where you are today, instructing others to understand the logic of computer programming!
My 'method' is keep bashing away at something, trying to gather info - but then get to a point where I give up frustrated, and go on to something else.
Eventually something works n it gives me the encouragement to continue.
Obviously that's not the best, but else I would have given up completely long ago.

My brick wall in this thread was
Quote:
My problem (so far) is how to store without being overwritten by following frame........
Tried to research but didn't get to a conclusion.....
JMW is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK


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 07:17 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.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.