One of the great things about movies set in space is that the writers have the opportunity to come up with some fantastically crazy situations. Just look at the planet Sovereign, revealed at the beginning of Guardians of the Galaxy Vol. 2. Don't worry about why the Guardians are on this planet too much—instead, let's just focus on the planet itself. It looks something like this:

It's fantastically awesome—and I'm OK with that. However, there is a small physics problem here. Planets, you might have noticed, are spherical. The planet Sovereign is decidedly not. But why are planets spherical? Is there a physical reason why a planet might have ended up looking like some sort of fat, intergalactic caterpillar? Perhaps I can answer this question with some python models.

Modeling a Planet

What is a planet? It's essentially a collection of mass that is mutually attracted to each other through the gravitational interaction. I can model planet formation by using large spheres that interact gravitationally (this is what I started when I started investigating the totally made-up concept of gravity balls). Instead of a planet being made up of 1024 kilograms of stuff, let's say instead that I have maybe 100 balls. Of course if there was only a gravitational force between these balls, they'd just glom together. So I'll add two additional forces. First, there will be a drag force that is proportional to each ball's velocity (this will make everything eventually settle down). Second, I will add a spring-like force between touching balls. When a ball overlaps another ball, there will be a force pushing them apart that will be proportional to the distance they overlap.

The best way to make a model with 100 balls is to start with just two balls—so I made a program that shows just that. Click the "pencil" to see the code for the collision and "play" to run it again.

Now that it works, I just need more balls. Here is an animation for 100 balls. This looks similar to my gravity balls program, except there is a spring force pushing balls apart. If you want to see the code, check it out here.