2026-09-22 Harsha Physics engine
This lerpette is unfinished3 problems
Write the heading as
physics-engine/point-dynamics/mixtape.md## The Loop {#the-loop}.Add
physics-engine/point-dynamics/code/the-loop/js/index.tswith a default-exported runtime.Add physics-engine/point-dynamics/code//.
physics-engine/point-dynamics/
Point bodies dynamics
A physics simulator solves the equations of motion using an integrator to iteratively advance the state through time. In simpler words, we use newton's laws of motion to update positions and velocities of bodies over small time steps.
In this article, we shall look at a simple physics simulation loop by building an n-body simulation. We shall start with a single particle under a spring force, and then build up to n-bodies that exert gravity on each other, which should not be that different qualitatively.
The Loop
Some terminology we need to familirize ourselves first -
- State - the quantities that define the configuration of the system at that point of time. In this case (positions, velocities).
- Integrator - a numerical method that takes in current state, acceleration and time step size and estimates the state at the next time step.
It would look something like this -
Let's now take a look into the integration step. Let's say we start with state . To calculate the next state , the most intuitive way to do it is just apply newton's equations on state at time .
Okay, now onto the code.
Other lerpettes