The target of this assignment is to experiment with simulation. Based on the six project options given to us, I accomplished the following:

#### Cloth Models Implemented

- Mass-spring cloth simulation
- Constraint-based Cloth Simulation

#### Numerical Integration Methods

- Position Verlet
- Explicit Euler

I also attempted to implement self-collisions for better visual effect, but my method is not ready for real-time.

My goal for this assignment was to create an environment where people learning about simulation techniques could have a playground to explore the different variables in a simulation engine. Although this is only for cloth, being able to change the integration method and the cloth model allows me to see how the cloth is affected in real time. I also added controls for adding different kinds of springs/constraints, so that we can clearly see the effect of each kind of spring/constraint on the simulation.

Additionally, I exposed the constants that I used in the implementation, such as damping, time step, number of iterations for constraint solver, and so on. We can play with this as we wish.

### Some Findings

#### Integrators on a Mass-Spring system

For spring-mass cloth model, I both integration methods will explode for Spring Constant = 2 and timeStep = 0.13. Actually, the creator of Box2D (a 2D physics library I have been experimenting in for my final project) gave a talk at GDC where it was explained how eigenvalue analysis can inform on what the limits of a mass-spring system are. [1]

In particular, for Explicit Euler, it is unstable for angular frequency and timestep more than 0. And it is shown that semi-implicit Euler is stable if angular frequency * timestep <= 2. It didn’t give any mathematics for position Verlet integrator, but based on just my experimentation with values, they seem to explode about equally on a mass-spring cloth.

This seems to be wrong to me, because position Verlet is supposed to be 4th order accurate (integrator error decreases proportional to the fourth power of the time step) [0]. I have to investigate more to find out why.

#### Constraint-based Model

Originally, I implemented this because the mass spring system seemed to look too elastic, based on videos and demos I’ve seen in and out of class. However, I found that for the constraint-based model, elasticity is directly linked to the density of the grid. For me, since I directly use mesh data for the point-mass grid, this means the smoother the cloth, the more elastic. I can think of some ways to have a finer point-mass grid than the cloth mesh. It seems that adaptive remeshing is the way to go for realistic-looking cloth simulation, anyway.

#### Adding pins for different cloth models

In trying to pin the cloth, I found that for my constraint model, the center pin always gets corrected more than the edges if I pin it after starting the simulation. This makes sense since the center point has more constraints. But it is not really what I want because pins should make them fixed at a certain point. What I am doing right now is to put the pinned points back, and then fixing all the constraints again. I will try to increase the “strength” of the pin over the constraint; I didn’t have time for it this round.

For the mass-spring model, I used the new position of the cloth to get a force or a velocity (depending on the integrator). This seems to work pretty well!

#### Adding “collisions” to each cloth model

I have not implemented this (although I did try my hand at making self-collisions), but for the constraint based model, it seems to be straightforward by placing another constraint on the point-masses to the surface of the colliding object. I will have to do more reading for the spring-mass model.

### Next Steps

Thinking about my final project, it might be worthwhile to keep using three.js. I had spent a good amount of my time on the assignment wrestling with the Python wrapper of the OpenMaya API before finally giving up; and the C++ API for Maya takes a lot of legwork before you can get off the ground. Since three.js utilises WebGL, it’s pretty flexible, especially next to Processing which was another thing I looked into using before I got Box2D up and running.

On another note, I feel like I did a good job writing this assignment in a way that could be more easily extended to something related to energy-momentum methods which I was thinking of exploring for the final project. It is really easy for me to implement different integrators and different cloth models in this simulator.

After reading [2], I was pretty convinced by the eigenvalue analysis for the mass-spring systems and wanted to have actual simulations show the stability against angular frequency and timestep, so my next steps for now are:

- Figure out why my Verlet integrator seems to be as unstable as the Explicit Euler
- Add Implicit and Symplectic Euler to my integration methods in this cloth simulation

### References

In order of importance/relevance:

[0] Cloth – Matthew Fisher

[1] Cloth Simulation and Manipulation – Ken Toh

[2] Numerical Methods – Erin Catto

[3] Simulating Cloth and Ragdolls (Jakobsen) in Processing