Movement Equations - SC-SGS/surviving-sarntal GitHub Wiki
Our physics engine is based on impulses and momentum as proposed by Baraff.
Since our game is two-dimensional, we are able to reduce his movement equations and receive the following system of partial differential equations:
We devise a simple, yet effective symplectic Euler solver for this equation:
$$
\overrightarrow{P}^{t+1} = \overrightarrow{P}^{t} + \delta t \cdot F^{t}\\
\overrightarrow{x}^{t+1} = \overrightarrow{x}^{t} + \delta t \cdot \frac{P^{t+1}}{m}\\
L^{t+1} = L^{t} + \delta t \cdot \tau^{t}\\
\theta^{t+1} = \theta^{t} + \delta t \cdot \frac{L^{t+1}}{I}
$$
Here, the force $\vec{F}^{t}$ and the torque $\tau^{t}$ are to be read as the sum of all forces or torques applied to a polygon at time step $t$.
A body force only changes the polygon's linear momentum.
In contrast, a surface force $\vec{F}$ applied at a point $\vec{p}$ changes linear and angular momentum.
It generates a torque
$$
\tau = (\vec{p} - \vec{x}) \times \vec{F}
$$
Disregarding collisions, only the gravitational force is considered in our simulation.
It is applied as a body force.
$\rightarrow$ Learn about Collision Detection here.