This program simulates a piece of cloth by discretizing it into a 256×128 grid of vertices connected by a network of springs: nearest-neighbor, diagonal, and second-nearest-neighbor connections along both gridlines and diagonals. Each spring contributes potential energy V=21k(x−Δ)2 where Δ is its rest length, and the system evolves under Newtonian mechanics.
To combat numerical instability and add realism, the simulation incorporates spring drag forces proportional to the velocity difference between connected vertices. The cloth is dropped from a raised position under gravity and settles into its lowest energy configuration.
Controls: Click and drag to orbit, scroll to zoom.