planets.js

Two planets pulling each other. F = G · m₁ · m₂ / r²
G (gravity strength)1.0
Planet A mass500
Planet B mass500
distance (r)–
force (F)–
The pull() function (shown on slide 11) computes the gravitational force between two bodies and updates their accelerations. Each body pulls on the other equally — that's why they orbit.