Jump to content

Recommended Posts

Hey there folks!

I'm taking a stab at developing a plug-in. I want to simulate orbital decay, using the law of exponential decay, displayed as a function. A(t)=A0ekt. Now, knowing that formula... What types of codes should I use? Or is there some sort of hidden option programmed into the game that I don't know about?

Or is this just a lost cause?

Thanks in advance for any help anyone can give me!!!

Link to comment
Share on other sites

I actually wanted to develop something similar. In the game floating point errors accumulate quickly and can change orbits considerably over time. My idea was just to consider this unavoidable shifting around as orbital decay and give the players tools to manage it. I wanted a module that I could dock to my station, which would then be entered with a target orbit through a menu. It would then automatically (or give data so you could do it manually, not decided yet) correct the orbit using the appropriate amount of propellant available.

The problem is that orbits do not decay/change in KSP when you're not within 2.5 km of the craft. This is the nature of the on-rails simulation that is pretty necessary: you'd suffer horrible lag without it. Plus it means orbits are easily predictable for rendezvous and stuff. Your idea would not work unless you were focusing the craft 100% of the time (I believe, correct me if there's a work around somebody), which would be pretty boring. You'd only suffer atmospheric drag while controlling that specific craft.

Anyways, I'm not a modder, but I can do basic programming and I've been browsing the tutorials to figure out how to make such a mod myself. This was inspired when I tried to do something that KSP just couldn't do, as documented in my old "How To" thread. I'm mostly posting to say that I'd be extremely interested in any mod that incorporates orbital decay. I have some ideas how to get around the on-rails limitations, though it wouldn't be 100% accurate.

Edited by AceMgy
Link to comment
Share on other sites

Your idea would not work unless you were focusing the craft 100% of the time (I believe, correct me if there's a work around somebody), which would be pretty boring.

As far as I know packed craft aren't set to read only, they simply have the physics system turned off. So while you can't apply a force to them and expect anything to happen you shouldn't have any trouble editing their orbital parameters. It's easy enough to check, just try hyperedit on an uncontrolled craft and see if it'll move it - you'd be doing exactly the same thing but more gradually.

Link to comment
Share on other sites

As far as I know packed craft aren't set to read only, they simply have the physics system turned off. So while you can't apply a force to them and expect anything to happen you shouldn't have any trouble editing their orbital parameters. It's easy enough to check, just try hyperedit on an uncontrolled craft and see if it'll move it - you'd be doing exactly the same thing but more gradually.

So your plan would be to periodically check all orbiting craft, calculate the amount of orbital decay based on mission time, then teleport them to their new location? Sounds good but I hope it doesn't overload the game with those calculations: we don't want the game to stutter every time this is done. Shouldn't cause too much problem with rendezvous unless you're planning one way in advance.

And I'm assuming it'd be easy to modify the craft's propellant reserves every time this is done? My rough idea for doing my orbital correction module (in horrible, sloppy pseudo-code) was:


Player initiates timewarp / changes focus
-> Calculate difference from target orbit
-> Calculate theoretical delta-v needed to correct

if propellant sufficient:
-> Subtract amount of propellant required for delta-v
-> Teleport craft to proper orbit
-> Resume timewarp / change of focus
else:
-> Cancel orbital correction
-> Warning message: "Your station is out of propellant!"

But that's assuming you can't teleport a craft when it isn't focused or the game is in timewarp. So could I just wrap this up into a big timestep, say 5 seconds or more? That'd be real-time, not game-time, as timewarp would lag horribly otherwise.

Edited by AceMgy
Link to comment
Share on other sites

So your plan would be to periodically check all orbiting craft, calculate the amount of orbital decay based on mission time, then teleport them to their new location?

You always keep the orbit passing through the current point, but you change the direction of travel so it passes closer to the planet in the next frame/second than it would otherwise have done. I'm guessing you'll have to change the eccentricity (increase AP to PE, decrease PE to AP) and shrink the SMA, although I'm not sure if you'll need to change the other parameters as well.

Link to comment
Share on other sites

Well yeah, for atmospheric drag all you have to do is reduce the magnitude of the velocity vector by a certain factor dependent on atmospheric pressure. It's direction wouldn't change as there's no torque involved. The orbital parameters would fix themselves...

And now I realize that the persistence file might save the orbital parameters and not the velocity vectors of each craft. I'm at work so I can't check it, but it would simply be a matter of calculation if that's the case. I can look into it deeper when I get home, but it would be the same as burning a little bit retrograde. Your apoapsis / periapsis drop a bit and the arguement of periapsis moves if you're not at either the apoapsis or periapsis. Gonna have to get my old textbook out.

Link to comment
Share on other sites

I wonder if it would be possible to do this just making it an extension of the existing atmospheric drag that is in game. If I could figure out how to apply that code to a craft when it's out of the atmosphere, and make it just incredibly minute, if that would work. Otherwise, figuring out how to input that formula into the equation would be interesting.

On the other hand, if I were to just make it an option to engage orbital decay at will. So, if you get tired of it, you can just turn it off and forget about it. (Like for timewarp, so it doesn't take you down immediately.) That way, you'd only have to worry about it as long as you're operating that craft.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...