I have a video that explains this better, although I’m unsure if I’m allowed to post outside links here (just youtube).
Pseudo-Realtime N-Body Orbital Integrator
Alright, I’ll try to keep this short. I took a jab at coding an orbit simulator. After playing around with patched conics, I decided to use an N-Body system instead. This yielded me more flexibility. If you are familiar with KSP, I do not use any spheres of influence (Any encounters are purely symbolic, there is no ‘handshake’ between celestial bodies). Instead, I calculate the gravity gradient using N-Body physics. This approach allows me to simulate a variety of celestial mechanics phenomena, such as Lagrange points and constant forces acting on a projectile, like solar pressure. Interestingly, this also supports long burns. To make the simulation more user-friendly, I’ve added a time compression feature. This is particularly useful for long orbits, where waiting three days to approach a target is impractical.
Here, I have an object that I put into a trans-lunar injection. The green track is a maneuver I’ve set up right before the encounter (I say encounter, but once again, there is no sphere of influence). This maneuver track gets me in a return trajectory back to earth. I’m still working on refining the user interface and trajectory representation, so any feedback would be greatly appreciated.
Lagrange points!!!
All distances you see here are distances from point masses, not altitude. Also, that little panel on the bottom right is unnecessary, as I’m no longer using a patched conics model. While it was cool playing with Keplerian orbital elements, they are really unreliable at highly eccentric orbits. In fact, they were a burden on server processing when solving Kepler’s equation.
Lunar capture burn!
It’s buggy, it’s clunky on orbit baking, but other than that it runs smooth. Oh, yeah. By pseudo-realtime, I mean I bake the orbits whenever an unpredicted change in velocity is detected. I tried realtime rendering, and boy was it unreliable and jank.
Edit: I forgot to mention, the mean elapsed time in the bottom right is bugged. It will occasionally read 3 months time-of-flight for a single orbit. It’s just a read error on the serverside.