You are browsing as a guest. Sign up (or log in) to start making projects!

4h 1m 57s logged

Umbra — Kepler’s Equation Nearly Broke Me

  • So remember in the first devlog when I said I spent 2+ hours just getting the orbit right? Turns out “right” was still wrong, the planet was moving at constant angular speed the whole time, which is basically not how orbits work

Real orbits speed up near the star and slow down far away (thanks Kepler), so I had to actually solve Kepler’s equation properly instead of faking it
Problem is M = E − e·sin(E) has no closed-form solution for E, you can’t just rearrange and solve for it like a normal equation, which I did not know going in and briefly panicked about

Ended up using Newton-Raphson to solve it numerically, feels very full circle after doing the same kind of thing for my EPQ (orbital sim for near-Earth objects), except this time it’s converging in like 5 iterations instead of me validating against JPL Horizons for weeks lol

  • The difference is honestly crazy to look at now, the planet visibly rips through periapsis and crawls through apoapsis instead of just gliding round at one speed the whole way, which is exactly what real eccentric orbits do

Pretty happy with this 4 hours cause it means I now have actual physics rather than some fake thing only added for the visuals.

below are some snippets from the solvers but not the full code of course

0
2

Comments 0

No comments yet. Be the first!