Another salvaged artefact: an old animation of a rectangular cloth draped over an invisible donut-shaped table.
It’s nicely rendered in POV-Ray, but there are serious flaws in its computation:
- The cloth itself is infinitely stretchable and 100% elastic.
- The surface of the table resists cloth points; but the edges of each are intangible. That’s why the the cloth will contract into the centre. (The cloth will not obstruct itself, either.)
- There’s no air — a cloth simulation looks more “billowy” with a gentle breeze.
It’s simulated as a simple 100×100 array of points, with orthogonal connections to nearest four neighbours. The connections are springs.
Flaw #1 arises because the spring model is as simple as can be: a force towards the natural length, in proportion to the distance from that length. At the time I was experimenting with damping, but this was fraught with complications, around determining the velocity of expansion/contraction and calculating a braking effect as a proportion of that. It’s a matter of keeping track of the coordinate transformations — I think the damping effect was correct, but I was fatigued from getting that far and muddled about how to apply that in the direction of the spring If I can reconstruct this animation’s algorithm I’ll have a another go at figuring it out.
I’m not sure about Flaw #2. It may come down to giving the table a thickness (and corresponding vertical surfaces) that is greater than the maximum spring length in the cloth. This is fine for the table, but will not stop the cloth from flowing through itself (and almost becoming inverted, as shown in the animation). Preventing this requires proper collision detection, which is only faked in the case of an abstract table surface.
Flaw #3 I’ll tackle if and when I’ve learned a bit about fluid dynamics. ;-)