A basic three-body simulation written in Rust. Used macroquad for graphics.
Each Body struct is initialized with position, velocity, acceleration, mass, and force (there are some other values but those are not as relevant).
On each update, the force between two bodies is calculated with Newton's Universal Law of Gravitation:
Then,
From there, basic kinematics equations use dt or
I recently watched the 3 Body Problem show.