# SpringCloth

**+**

This program simulates a piece of cloth by discretizing into a grid of $256\times 128$ vertices, connected together by springs in the following configuration:

- Each vertex is connected to its nearest neighbors along gridlines
- Each vertex is connected to those which lie adjacent across the diagonal of a square
- Each vertex is also connected along gridlines to vertices at distance 2 away.
- Each vertex is also connected along diagonals vertices at distance 2 squares away.

Altogether this is a lot of springs! Giving each spring the potential energy $V=\tfrac{1}{2}k(x-\Delta)^2$, where $\Delta$ is the rest length of the given spring when the cube is a rigid Euclidean square, we simulate the physics using Newtonian mechanics of these (thousands!) of coupled harmonic oscillators.

To deal with numerical instability and add realism, we further incorporate dissipation into the model, adding a spring drag force which is proportional to the difference in velocity between the two masses at the end of a given spring.

Right now the simulation is not very interactive (it was just a proof of concept), it just drops from a raised position under gravity, and settles into its lowest energy state. Check back in the future for more excitement!

**+**