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:

$$ \frac{\textbf{d}}{\textbf{d}t} \begin{pmatrix} \overrightarrow{x}(t)\\ \overrightarrow{P}(t)\\ \theta(t)\\ L(t) \end{pmatrix} = \begin{pmatrix} \frac{\overrightarrow{P}(t)}{m}\\ \overrightarrow{F}(t)\\ \frac{L(t)}{I}\\ \tau(t) \end{pmatrix} $$

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.

⚠️ **GitHub.com Fallback** ⚠️