Jump to content

Calculating orbits yourself


Xetalim

Recommended Posts

Could you be a bit more specific? What do you want to compute based on what information? It is relatively easy to do things like compute the necessary delta-V for a transfer from one orbit to another. Or to compute amount of time it would take you to go from periapsis to apoapsis. Your question doesn't make it clear what exactly you want to know.

Link to comment
Share on other sites

On any information, current height, speed and heading?

If you can measure angle between your current direction of motion and a line from center of the body to your ship, yeah. Call that angle θ. It's also more convenient to use distance from center, which you can compute as r = h + R, where h is the height above the body and R is the body's radius. For KSP, you can look up the radius in the wiki. Then your specific angular momentum is L = v r sinθ. Here, v is your ship's speed. Also, you know the specific energy, which is E = v²/2 - MG/r, where M is planet's mass and G is the gravitational constant. In wiki, you can look up the value μ = GM, called gravitational parameter, directly.

At the periapsis and apoapsis, θ = 90°. And values of L and E remain constant through the orbit. So you can solve the following system of equations.

vaps raps = L

vaps²/2 - μ/raps = E

The first equation can be written 1/raps = vaps/L. Which I can now substitute into second equation.

vaps²/2 - μ vaps/L - E = 0.

That's a quadratic equation, which has two solutions.

vaps = μ/L ± Sqrt(μ²/L² + 2E)

And, of course, you can obtain raps = L/vaps now, which will give you two solutions corresponding to apoapsis and periapsis. You can use these together to determine semi-major axis and eccentricity based on equations from Sternface's link.

Edited by K^2
Link to comment
Share on other sites

Please note all the above is perfectly valid with the assumption that no gravitational fields from other bodies (else than the one your ship is orbiting around) exist. This is exactly what KSP does, and the formulas provided before are perfectly good to obtain orbital elements with such assumption. Generally speaking, this is the 2-body problem (the two bodies actually orbiting around their common center of mass, without perturbation from other bodies), that allows for a perfect numerical solution.

However IRL that is often seen as a gross approximation. Calculation of true orbital parameters is one peculiar aspect of the n-body problem (http://en.wikipedia.org/wiki/N-body_problem), and there is no simple mathematical way to solve it (this is a NP-complete complexity class problem in computational theory). There is no easy, elegant formula able to predict position of a body in a n-body system; instead, solution to the n-body problem can be obtained by integration of the polinomial equations of motion over time, as it is a convergent series. In case anybody is interested, I can provide a document describing interpolation formulas used to predict orbital movements in a n-body system, used in another space simulator.

Link to comment
Share on other sites

OK, looks like I've found the right thread. I've been meaning to ask why my numbers don't add up. I am familiar with the orbital mechanics equations, and applying the simple formula for circular orbit velocity given altitude and mu, I figured I could calculate mu based on such things as the given alt for geosynchronous orbit around Kerbin. (Period is 6 hours.) But the numbers don't quite add up... using the Mun in these equations seem to give a different value for mu. (Then, I've heard that the heavenly bodies here don't follow Newtonian physics so the comparison may be wrong.)

1. Does G (grav. constant of this universe) vary or is it constant?

2. Can anyone give me a sample number crunch or two so I can see what I might be doing wrong?

Cheers-

MT

Link to comment
Share on other sites

heavenly bodies here don't follow Newtonian physics so the comparison may be wrong.)

1. Does G (grav. constant of this universe) vary or is it constant?

2. Can anyone give me a sample number crunch or two so I can see what I might be doing wrong?

The heavenly bodies themselves are on rails. I haven't checked if orbits make sense with gravitational parameters of the parent bodies. But yeah, if you use period of the Mun to get gravitational parameter of Kerbin, it doesn't necessarily have to make sense.

For ships, however, gravitational constant is consistent. So if you have a ship in orbit, you should be able to compute gravitational parameter to within the precision with which you can get the values for period and semi-major axis. Keep in mind that apses are given with respect to mean sea level, so you have to add planet's radius. Alternatively, you can make measurements at different orbits and estimate that as well. Math is going to be a bit more complex for that, though.

Link to comment
Share on other sites

The heavenly bodies themselves are on rails. I haven't checked if orbits make sense with gravitational parameters of the parent bodies. But yeah, if you use period of the Mun to get gravitational parameter of Kerbin, it doesn't necessarily have to make sense.

For ships, however, gravitational constant is consistent. So if you have a ship in orbit, you should be able to compute gravitational parameter to within the precision with which you can get the values for period and semi-major axis. Keep in mind that apses are given with respect to mean sea level, so you have to add planet's radius. Alternatively, you can make measurements at different orbits and estimate that as well. Math is going to be a bit more complex for that, though.

Ah, altitudes not radii given. Check. I'll try the calcs again, thanks much! :wink:

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...