Nivekk / KOS

Fully programmable autopilot mod for KSP.
Other
80 stars 30 forks source link

Could there be a way to read "Closest Approach"? #275

Open Dunbaratu opened 10 years ago

Dunbaratu commented 10 years ago

file:http://imageshack.com/a/img51/5956/x5uk.jpg

(Not my image - taken from a google search)

I don't think there's currently any way to obtain that "closest approach" information in a kos script. This sort of makes encounters rather boolean. Either you're close enough to have KSP call it an 'encounter', or you're not. If you're not, the script can't tell the difference between an 'almost' encounter of say 1 million km, versus a "not even close" pass of 40 million km.

Being able to obtain that information would really help speed up algorithms to iteratively search for an encounter, as it would allow you to perform "geting warmer / getting colder" search techniques.

adammada commented 10 years ago

I wrote plugin which did that (now abandoned) - and KSP don't have simple internal function to do it. So it have to be code from other plugin, like Protractor (is on GPL3), but i see that currently soruce is missing.

http://forum.kerbalspaceprogram.com/threads/21544-22-Protractor-Rendezvous-Plugin-v-2-4-3

But i think that much better would be some function to get Planet position at certain time and your position at certain time. Those are simple functions in KSP, just need mapping.

That way you can build your own code to find closest approach, and also do other stuff.

baloan commented 10 years ago

"Either you're close enough". I reckon KSP calls it an encounter when you enter the bodies SOI. Btw, I am working on a method/script to calculate Hohmann tranfers - at least in 2D, and yes, it should be possible to calculate orbital angles as a function of time. I don't know yet how accurate it will be. I will want to choose a trajectory which comes closer than the SOI to make it work. Full 3D will only be possible when there is access to the ships and bodies' ephemeris data in the script. I am wondering how this is handled in KSP as every time a ship comes closer to 100km of a body the frame of reference is changing.

Dunbaratu commented 10 years ago

The problem with Hohmann transfers is that they presume you start from a circular orbit and are going to meet a body that is on a circular orbit. They don't work for the general case where your target body can be a planet in an eccentric ellipse.

MaHuJa commented 10 years ago

Another reason for this is when you're trying to approach a different vessel in orbit around the same body as you are. There won't even be an "encounter" in that case.

The simplest method would probably be that you select your target, and ask for closest approach, where it goes along all the conics (as it does when finding what you're encountering) and running some code (e.g. ripped from mechjeb) that tells you about your closest encounter, returning the result to the user.