Gravity Simulator
Change the mass of a star, the distance of a planet and the planet's speed, then watch what happens to its orbit. The numbers come from Newton's law of gravity, and the equations are below.
- Circular orbit speed here
- Planet's starting speed
- Escape speed here
- Orbit shape
- Length of one orbit
How the simulator works
Gravity pulls the planet toward the star with a force that grows with the star's mass and shrinks with the square of the distance. Newton's law of universal gravitation gives the acceleration:
a = G × M / r²
Here G is the gravitational constant, 6.674 × 10⁻¹¹ m³ kg⁻¹ s⁻², M is the star's mass and r is the distance between the two. The simulator recalculates this pull many times per animation frame and moves the planet accordingly.
The three numbers to watch
Circular orbit speed is the speed at which the planet's path bends at exactly the same rate as the star's pull, giving a circle: v = √(G × M / r). For Earth at 1 AU from the Sun, that is about 29.8 km/s.
Escape speed is √2 times larger, about 42.1 km/s at Earth's distance. At or above it, the planet never comes back.
Length of one orbit follows from Kepler's third law: T = 2π × √(a³ / (G × M)), where a is half the orbit's longest diameter. With the default settings this gives about 365 days.
Try these experiments
- Set the star mass to 4 and keep the distance at 1 AU. The circular speed doubles, because it depends on the square root of the mass.
- Reset, then lower the starting speed to 70%. The orbit becomes an ellipse and the planet swings closer to the star.
- Reset, then raise the speed to 145%. The planet leaves for good, because that is above the escape speed.
- Reset, then set the distance to 4 AU and the speed slider to 100%. One orbit now takes 8 years, as Kepler's law predicts.
What this model leaves out
This is a teaching model, not a mission planner. It treats the star and planet as points, keeps the star fixed in place, ignores other planets, and does not include general relativity. A planet that gets too close to the star is simply marked as a collision, using a fixed distance of 0.02 AU. Real solar systems are messier, so treat the results as a clear picture of Newtonian gravity and not as a precise prediction for any real planet.