# Sun and Planets

Bodies · mechanical systems

```
gravity
m=1      x=0    y=0
m=0.001  x=1    y=0  vx=0  vy=1
m=0.001  x=2.2  y=0  vx=0  vy=sqrt(1/2.2)
```

[Open in the app](https://www.wavelace.com/app#p=85) · [This page](https://www.wavelace.com/presets/sun-and-planets)

### The setup

A star of mass 1 sits at the origin with no velocity given, so it starts at rest. Two planets of mass `0.001` start out along the `x` axis, at `1` and `2.2`, each moving straight across its own radius. At a thousandth of the star's mass they barely feel each other, which is why this looks like two clean circles rather than a three-body problem.

### Why those speeds

A circular orbit needs the pull to be exactly the turning force: `M/r² = v²/r`, so `v = √(M/r) = √(1/r)`. That is the `vy=1` on the inner planet and the `vy=sqrt(1/2.2) ≈ 0.674` on the outer, written as an expression, which the spec accepts. Divide the circumference by the speed and the period is `2π r^1.5`. Inside that is `2π ≈ 6.28` seconds, outside `2π · 2.2^1.5 ≈ 20.5`, a ratio of `3.26`. Period squared against radius cubed is Kepler's third law, published in 1619, and it falls out of the same one-line sum.

### What the star does

Watch the middle. Giving the star no velocity leaves the system with a total momentum of `0.001 · 1 + 0.001 · 0.674 ≈ 0.00167`. So the whole picture slides gently upward, a tenth of a unit in a minute, with the star's own small wobble on top. Nothing is wrong: momentum is conserved, and it was not zero to begin with.

### Try

- Stop the drift: add `vx=0  vy=-0.001674` to the star's line, and the middle of the plot stays put.
- Add a third planet on a line of its own, `m=0.001  x=4  y=0  vx=0  vy=sqrt(1/4)`. It circles out at 4 with a period near `2π · 8 ≈ 50` seconds.
- Slow the outer planet, `vy=0.5`. That is too slow for a circle, so it falls into an ellipse that dives in to `0.83` and swings back out.
- `Top` in the deck for the orrery view, both orbits seen flat.

### Read more

- [Kepler's laws of planetary motion](https://en.wikipedia.org/wiki/Kepler%27s_laws_of_planetary_motion)
- [Circular orbit](https://en.wikipedia.org/wiki/Circular_orbit)
- [Two-body problem](https://en.wikipedia.org/wiki/Two-body_problem)
- [Barycenter](https://en.wikipedia.org/wiki/Barycenter)
