Show HN: Rocket Launch and Orbit Simulator

1 day ago (donutthejedi.com)

I (17y/o) have been developing a rocket launch simulation that allows the user to explore what it's like launching a rocket from earth and putting it into orbit. This idea originally started as an educational simulation but as i've gone more down the rabbit hole the more i've wanted to make it realistic. The problem is that I've never had a formal orbital mechanics class or anything like that so I don't know what I'm missing, what I currently have implemented is:

  Variable gravity
  Variable Atmospheric drag (US Standard Atmosphere 1976)
  Multi-stage rockets
  Closed-loop guidance / pitch programs (works well within ranges 350km to 600km)
  Orbital prediction and thrusting options to change your orbit.

The feedback I'm looking for is: UI improvements and possible future physics implementations that I can work on.

Current code and physics can be found at: https://github.com/donutTheJedi/Rocket-Launch-Simulation

What did you use for closed loop guidance? If you aren't aware of it NASA has a lovely paper called UPFG "Unified Powered Flight Guidance" [1] used for the space shuttle. This was implemented and made more universal for KSP (of course) by Przemysław "Noiredd" Dolata as PEGAS "Powered Explicit Guidance Ascent System" [2]

If it's your thing you could try implementing it and getting a single continuous burn to final orbit.

Awesome work BTW!

[1] https://ntrs.nasa.gov/citations/19740004402

[2] https://github.com/Noiredd/PEGAS

Edit: I now see it's on your roadmap, so I guess it is your thing.

This is awesome, great work! There’s a huge audience for something like this based on the popularity of Kerbal Space Program.

Biggest low-hanging fruit UI improvement would be mobile responsiveness. It was a bit challenging testing on my phone.

I think it's a good start, but the user experience and the color theme make the simulation cumbersome to absorb. Maybe you can do a theming exercise with an AI. The zoom feature is highly sensitive. It's not intuitive at first on what the user should do or take away from the simulation. The events feature is great, and essential.

Looking forward to seeing the next iteration. Nice work.

This is really neat and pretty fun to play around with!

How accurate are the simulations? I'm able to get orbit by turning 45 degrees as soon as I launch and then doing some minor burns at the height of the initial trajectory.

I don't feel like this strategy would work in real life.

  • Its fairly accurate as far as I can tell. Your right about the fact that It wouldnt work in real life due to the dynamic pressure your exerting on your rocket, using your method you get to about 150 kPa, Falcon 9 usually maxes out around 35 kPa so it would explode. Also it is a fairly fuel inneficent way of getting into orbit, but yes it is possible

  • Subtracting gravity losses, the largest effect of your 45 degree thrust vector would be sideways acceleration. Which is generally what you want, to get up to speed as quickly as possible, instead of wasting energy ascending vertically.

    We just don't do it on Earth because we need to get out of the atmosphere first for efficiency and structural reasons. But on the moon or another vacuum body, "diagonal kick followed by minor circularization burns at apogee" is pretty close to the optimal strategy. Even on Earth, it's similar to the trajectories proposed by SpinLaunch and other "space cannon" concepts.

How much AI was used vs manual lines?

  • Around 90% AI for syntax, I did alot of debugging manually. For implementing new features I would design them and do the reasearch then have a AI write lines for me and verify the work

    • It's a quick path to having something to play with but I'd encourage folks specifically wanting to learn something new or create something for a portfolio to try to have it be more the other way around: write 90% by hand, implement the features yourself, and have AI help you with the research and debugging (but not try to automatically write the code to fix the bugs). AI is really great at all of the things listed, but I guarantee if you were in an interview and someone asked you about this project your responses about how and why everything works would be 2x-3x stronger.

      If this was your 3rd time implementing an orbit simulator and you just wanted to get the bulk done quick so you could move on to work on new stuff then that's when having AI write the bulk & doing checking really works best as you're already an expert in what needs to be done rather than trying to learn about what needs to be done from someone/something else doing it for you.

      I say this as an orbital dynamics simulator in C++ having been one of my first big projects I put in a portfolio myself :). And I also like to use AI often, I'm not an AI hater in general, just I like to use in certain specific ways sometimes.

      Feedback on the UI side: It'd be cool if the stars used more random positions rather than sine/cosine looking patterns. There are lots of different approaches one could try (from simple random positions to very complex types of clustered randomness and brightness variation to realistic star maps). My suggestion would be to ask AI what types of approaches could be taken and try implementing whichever approach sounds the most fun!

      6 replies →

    • This breaks my heart, software modeling orbital mechanics is something I do for fun from time to time.

Why is it launching with a horizontal velocity? It initially moves to the right even when pointing up perfectly.

  • Thats due to the rotation of the earth, for the purposes of the simulation the earth is rotating at 408 m/s (earths rotation at cape canaveral) so thats why It appears its going sideways

    • When the rocket launches it already moves with earth's rotation at that latitude (and is stationary with respect to the ground). That's in fact the reason why many rocket launch sites are near the equator: Free velocity.

    • Don't rockets also start with the same horizontal velocity though, since nothing canceled it out when it got off the launch pad?

      It would be like jumping, and finding yourself ~250-400 meters away from where you lept by the time you landed.

      That said, neat project, and way fun learning experience. Good job.

      1 reply →

    • But the rotational velocity of the rocket is going to be very similar to Earth's at the launch site. Eventually the rotational velocity between ground and the rocket will begin to noticeably differ, but the launch trajectory starting at 408 m/s would look terrifying if it were that way in real life.

      3 replies →

Looks super awesome. Strong work! It showed the karman line at 98-99km. Maybe a tiny tweak needed.

I'm sure that city just *loves* being downrange of the launch site :)

JK, nicely done! lots of fun to watch.

  • Fortunately for it, that city is mounted on some antigrav sled and moves around to always stay ahead of the launch vehicle, safe from my totally not intentional attempts at crashing into it.

    Completely unrelated bug: pitch control can go down only to -5 degrees.

This is really neat.

I've been toying with the idea of building something similiar but with a bunch of different space stuff, like a calculator for different rotating space station geometries, mars/lunar cycler orbits, or solar shade sizes/distances.

It's been many years since I've done this kind of stuff in school and it's great to be able to refresh yourself on this stuff. The kind of UI you're using makes it really friendly and approachable, like a game.