# CS294-13 Assignment 4

## Cloth Simulation

## by Fu-Chung Huang

### System Description

In this assignment I implemented a spring based model for cloth simulation using implicit integrator and mass modification method for constraints. The techniques for the solver are described in the paper "Large Steps in Cloth Simulation" by David Baraff Andrew Witkin, appeared in SIGGRAPH 1998. I also referenced code from Hamilton Chong's website.

The spring model for cloth simulation use 3 kinds of springs: structural, shear, and bending, and this model is very easy to implemented for Modified-Preconditioned Conjugate Gradient solver.

Although the author claim the modified PCG solver for implicit integrator can solve for large time step, I felt it was not necessarily the case, and the stability also depends on various issues such as size of collision objects, coefficients of springs, and etc, so the result video still require a lot of tweaking parameters.

### Future Improvement:

1. Currently I didn't handle interaction with the cloth itself. As mentioned in the paper, it could possible be done by adding vertices to triangle checking constraints, but I haven't put that into the code, so as can be seen in Result 1(Low K-BEND), if the cloth is too soft, then the cloth will penetrator through itself.

2. Laking adaptive simulation, and as my experiment shows that when the time step is too large(i.e. object's x + t*dv is too large relative to the size of object), or the spring constant is too small(too soft), then the simulation will explode. For correctness, it should detect(or undo) the time step and refine the time step.

3. Releasing contact. Currently there is still bug when releasing contact force. Although not shown in the result section, there are cases that when cloth falling on a object then slide down will cause a unreleased constraints, and drifting away in a direction parallel to the normal of the contact.

Result:

All th simulation are done on a 2.4GHz MacBook Pro computer. The memory consumption are quite low, and the simulation speed are "close to" interactive rate with a 31x31 grid of cloth.

#### Result 1: Cloth falling onto sphere

Video on the left simulate a high bending coefficient cloth, so it looks more stiff. However higher stiffness provide more stability.

Video on the rifght simulate a low bending coefficient cloth that is softer and looks more like a sheet of real cloth. (and you can see there is cloth peneratrating through itself, no self collision handling)

#### Result 2: Cloth swinging and hit a sphere

#### Result 3: Interaction with more objects

#### Result: Cloth falling on a sphere and then slide a bit.