Does anyone have an example of implementing Orbital Mechanics (preferably in XNA)? The code I am currently using is below, but it doesn\'t \"feel right\" when it executes. The
Newton-Raphson iteration is not a stable way to solve this problem (that is you can't get it right using so simple an integrator for the differential equation). Consider using a second (or higher) order solution: Runge-Kutta is good and is fairly easy to implement in this case.
From the point of view of numeric analysis, the problem of orbital mechanics reduces to that of solving the set of coupled differential equations:
x_i'' + G m_i \sum_{i != j} m_j r_ji/(|r_ji|)^3 = 0
where the x
's are three-vectors representing the positions of the bodies, the m
's are the masses of the same bodies, and r_ji = x_j - x_i
is the vector displacement between bodies j
and i
.