My very first project! A simple Newtonian gravity simulation around a point source (planet). No trigonometry used whatsoever!* Use arrow keys to move around, but gravity is always pulling on you. Press spacebar to launch yourself off of the planet's surface at a high velocity. The atmosphere slows you down in your orbit. Can you get into a stable orbit? R to reverse velocity C to clear trail X to toggle trail Z to set velocity to zero F to enter a CCW circular(ish) orbit (the calculations aren't perfect) M to toggle the moon (which really serves no purpose at this point and is very glitchy - sometimes you need to double-press M) Q/W is the shortcut to change gravity (this can be used to achieve negative gravity!) S to toggle shadows *Except in the calculation of the X and Y components of the vector when F is pressed.
This version is obsolete. I have fixed the math. https://scratch.mit.edu/projects/94196531/ If you liked this, check out my other project: http://scratch.mit.edu/projects/24018818/ Known bugs: -The orbiter does not maintain its velocity when crossing over the edge of the screen. -Crashing into the planet at a high enough velocity that the orbiter somehow comes to rest in the center of the planet (which is hard to do) causes the orbiter to be stuck in the center of the planet for a while until it comes flying out at a high velocity. -The orbits precess way too much. I'm not sure what's causing this. I would appreciate the wisdom of anyone more mathematically inclined than I. -If F is pressed repeatedly, the orbiter will slowly spiral into the planet. (effect greatly diminished with a recent change) -Orbiter sometimes passes through the moon... ? NOTE: The moon does not have its own gravity and is not planned to. If it did, stable orbits would not be possible. P.S. This project will no longer be updated as of February 2015.