+
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:
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!