Physics collision simulator
How it works Each ball is modelled as a rigid disk with mass proportional to its area: $$m = \pi r^2$$ Euler integration Position and velocity are updated each frame using Euler integration with timestep $\Delta t$: $$\mathbf{v}_{n+1} = \mathbf{v}_n + \mathbf{g} ,\Delta t$$ $$\mathbf{x}_{n+1} = \mathbf{x}_{n} + \mathbf{v}_{n+1} ,\Delta t$$ where $\mathbf{g} = (0, g)$ is the gravity vector (positive $y$ points down on screen). Collision detection Two balls $A$ and $B$ with radii $r_A$, $r_B$ and centres $\mathbf{x}_A$, $\mathbf{x}_B$ are overlapping when: ...