This article is about the film, but not the plot. If you want to see it, please read it carefully.

Among several films released during the Spring Festival, the Wandering Earth became a dark horse, flooding Weibo and wechat moments, and rocketing from a low screening rate to the top of the box office.

People who have seen the film may have a question, the solar system is so empty, why the earth in the “wandering” process, must die on Jupiter?

This leads to a concept that is often used in movies and television, but is actually common in space exploration:

The slingshot effect

When a craft flies close to a planet, it is affected by the planet’s gravitational pull: it speeds up as it approaches and slows down as it moves away. Due to the conservation of energy, the spacecraft enters and leaves the orbit of the planet with the same relative velocity with the planet, but the direction does change. Add in the velocity of the planet itself, and the velocity of the vehicle changes from an onlooker’s point of view. To take a more mundane example: If you smash a tennis ball into a wall with speed V, the ball will bounce back with the same speed V; If you hit an oncoming truck with speed U with speed V, the ball will bounce back at v + 2U (relative speed v + u plus truck speed u).


This could speed up (or slow down, depending on the Angle of contact with the planet) a space probe without burning any extra fuel. This may seem to defy the laws of conservation of energy and momentum, but the planet’s mass is so large that the change in speed is negligible.

The farthest man-made object from Earth is Voyager 1, which used Jupiter and Saturn to accelerate in succession.

Source: Wikipedia – Gravity boosting

In the movie, it’s Jupiter’s slingshot effect that humans use to gain more speed to escape the solar system.

Out of curiosity, I wrote a simplified simulation in Python (Pygame) of what would happen if Earth flew by Jupiter:

Using a gravitational slingshot to accelerate


If the speed is too fast or the distance is too far, the acceleration effect is not obvious


Too slow or too close to Jupiter


Decelerate with a slingshot


Video version

Python simulates the slingshot effect of Jupiter’s gravity https://www.zhihu.com/video/1079021435854548992

After a few tests, I found that the slingshot didn’t work that well. Too far away, it wouldn’t work. Too close, it might get caught by gravity and crash into Jupiter (the Earth would have been torn apart by the Roche limit before it hit).

As for what happens in the play, I won’t say much here.

In my simulation code, for visual purposes, the sizes of the Earth and Jupiter, and their relative distances, are out of proportion, otherwise they would be smaller. And in order to make the speed change more obvious, the speed of the operation has also been enlarged. So it’s not exact in absolute terms, but relative changes are calculated by the basic laws of physics.

Core code:

The coordinate difference between ground and wood
delta_x = (jupiter[0] - earth[0]) * k
delta_y = (jupiter[1] - earth[1]) * k
Distance between ground and wood squared
r2 = delta_x ** 2 + delta_y ** 2
Gravitation between earth and wood, law of universal gravitation
F = G * m * M / r2
# Angle between ground and wood
theta = math.acos(delta_x / r2 ** 0.5)
Gravitational components of x and y axes
fx = abs(F * math.cos(theta)) * sign(delta_x)
fy = abs(F * math.sin(theta)) * sign(delta_y)
# X, y acceleration, Newton's second law F = ma
ax = fx / m
ay = fy / m
# change in velocity, vt = v0 + at
vel_x + = ax * t
vel_y + = ay * t
# change in displacement, st = s0 + vt
pos_x + = vel_x * t / k
pos_y + = vel_y * t / k
Copy the code

Related parameters:

k = 1e7            # distance scaling parameter
m = 5.9742 e24      # Earth mass
M = 1898.7 e27      # Jupiter mass
G = 6.67259 e-17    # Universal gravitational constant
t = 1e5            # time scaling parameter
pos_x= 0           # Earth coordinates
pos_y= 550earth = pos_x. pos_y
vel_x= 300         # Earth speed
vel_y= 0jupiter = 700. 150 # Jupiter coordinates
v_j = 3            # Jupiter velocity
Copy the code

To test different effects, you can adjust the coordinates, speed and other parameters.

The concept of “gravitational slingshot” was mentioned a few years ago in “Interstellar” and “The Martian,” and I had been thinking about writing a simulation until I took advantage of “The Wandering Earth.” I have been looking forward to this film since July last year when I had not yet bought tickets. I have also read the original book. I was worried that there would be too few films, but I did not expect it to become so popular. Of course, there are many accidental commercial factors and the film itself has many shortcomings, but as a “science lover”, I am happy to see this. The aborted three-Body Problem movie may also have a chance to be resurrected.

I hope there will be more wonderful science fiction works in the future, and I also hope that more people can look up at the stars when busy with their heads.

Simulation code has been uploaded, please reply in the public account (Crossin programming classroom) keyword: gravity

═ ═ ═ ═

Other articles and Answers:

Novice Python | how to self-study guide | select Python q&a | | Python wordlist ai | | | creeper I use Python requests | | computer vision character player graphics Python | | a smart reduced barrage

Welcome to search and follow: Crossin programming classroom