Description
In this project I implemented a cloth model described in Discrete Shells by Grinspun et al. The cloth is modeled by an energy function which depends on the stretching of the edges of the mesh, the change in area of the triangles of the mesh, and the bending along the edges of the mesh. Integration is done using implicit Newmark. Rudimentary collision detection is performed against static objects.
The formulas for the energy function are really nasty so I used Maple to differentiate them (twice, for implicit integration).
The edge and triangle stretching forces are not so bad and the generated code was about 2,000 lines in cloth_maple.cpp.
The bend force is pretty hairy and produced just short of 30,000 lines of generated code in cloth_maple_bend.cpp.
The implementation of the Newmark integrator is in newmark.cpp.
The integration code there accepts an abstract sparse block 3x3 matrix class, for which I have two implementations - one for general sparse systems and another for symmetric positive definite sparse systems (using conjugate gradient).
Both of these implemenations use NAG as the back end.
Demo Videos
Flag
A flag with the vertices on the left side pinned.
![]() A video of the flag waving in the wind [divx]. [mov] |
![]() A longer clip with a more stiff cloth model [divx]. [mov] |
Hat
The hat-toss sequence from the Grinspun paper.

[divx] [mov]
Ball
A bouncy ball made out of a thin shell.

[divx] [mov]

