Is the semi major axis from the game files calculated from the Sun's surface or centre?
I'm trying to calculate resonant orbits (again) and I keep on not getting them because the 1.5 stock navigation system is straight ass when it comes to anything more complex than an homann transfer
In the game files it's measured from the center. The game itself however displays altitudes, so they are measured from the Sun surface. You need to add the Sun radius to have the corresponding radius.
How do you calculate them? With the third Kepler law I suppose? Here is how I proceed if that can help.
Usually I write T1²/D1³ = T2²/D2³ = constant
With T1 the orbital period of object 1, and D1 its sma. Then same thing with T2 and D2 relating to object 2.
The orbits being resonant translates to n1×T1 = n2×T2: object 1 completes n1 orbits in the same time as object 2 completes n2 orbits.
So:
(T1/T2)² = (D1/D2)³, and
T1/T2 = n2/n1
By substituting T1/T2:
n2/n1 = (D1/D2)^(3/2)
n1 and n2 are integers, and any couple of positive integers will make the orbit resonant.
With this formula, once you have determined your sma and the target's sma, you just calculate (D1/D2)^(3/2), then the purpose is to find the closest rational to this. For this, there's a very efficient method which is calculating the corresponding continued fraction. You can google this for more precisions, but here is how you process, you'll see, it's fast and easy.
If your ratio is r=1.4567 for example, you first split it as the sum of the integer part and the decimal part:
r = 1 + 0.4567
Then take f = the reciprocal of 0.4567, so:
r = 1 + 1/f
Here, f≈2.1896...
Split this into integer part and rational part, so:
r = 1 + 1/(2 + 0.1896)
You can cut the fractional part and get the approximation r ≈ 3/2, or continue the process:
f = 1/0.1896 ≈ 5 + ... so:
r = 1 + 1/(2 + 1/(5 + ...))
Now by removing the fractional part you have r ≈ 16/11 (1.4545...) which is much closer.
Then when you're satisfied with your approximation you just calculate what should be exactly your sma to make your orbit resonant.
You can also continue the continued fraction process, to have a more accurate approximation, but at the cost of a higher number of turns. It's just a matter of finding the best compromise.