Subsections

5 Discussion

5.1 Macri's Error

Equations (54) and (57) are very different from the equations obtained by Macri. Macri differentiated equations (28) and (29) and then rearranged to obtain two different formulas for $ \frac{\partial C}{\partial {\bf x}_m}
$ :

$\displaystyle \frac{\partial C}{\partial {\bf x}_m}$ $\displaystyle = -\frac{1}{\sin \theta} \frac{\partial \cos \theta}{\partial {\bf x}_m}$    

and


$\displaystyle \frac{\partial C}{\partial {\bf x}_m}$ $\displaystyle = \frac{1}{\cos \theta} \frac{\partial \sin \theta}{\partial {\bf x}_m}$    

Likewise, Macri obtained two different formulas for $ \frac{\partial^2 C}{\partial {\bf x}_m \partial {\bf x}_n}
$ . Macri suggested choosing the first set of equations if $ \lvert\sin \theta\rvert > \lvert\cos \theta\rvert $ . The rationale for this choice is presumably to avoid numerical problems and division by zero when $ \sin \theta=0$ . In order for the transition from one regime to the other to be smooth, they should be equal at some changeover point. However, it is not evident that there exists any changeover point where the two formulas are equal. Additionally, neither of these equations matches the numeric derivative of $ C$ . My equations, however, give a result identical to the numeric derivative.

Macri's approach fails because he doesn't consider the transition between his two bend formulas. My approach succeeds in these cases because it relies on a single formula for all bend angles, instead of switching between formulas at critical bend points.

I derived equation (54) by the following logic. Define $ y=\frac{\sin\theta}{\cos \theta}$ , and $ \theta = \arctan y$ . Then, $ \frac{\partial \theta}{\partial {\bf x}_{m_s}}
=\cos^2\theta
\frac{\partial y}{\partial {\bf x}_{m_s}}
$ . Differentiating $ y$ , we obtain

$\displaystyle \frac{\partial y}{\partial {\bf x}_{m_s}}
=\frac{\cos\theta
\fra...
...\sin\theta
\frac{\partial \cos\theta}{\partial {\bf x}_{m_s}}
}{\cos^2\theta} $

and thus,

$\displaystyle \frac{\partial \theta}{\partial {\bf x}_{m_s}}
= \cos\theta
\fr...
...\bf x}_{m_s}}
-\sin\theta
\frac{\partial \cos\theta}{\partial {\bf x}_{m_s}}
$

The derivation of (57) follows directly from differentation of this equation. In some ways, this definition feels a little circular due to the introduction of the artifical $ \arctan$ term. I believe that the derivation is nevertheless correct. One area of serious concern, however, is the fact that the second derivative does not exhibit typical symmetry: $ \frac{\partial^2 \theta}{\partial {\bf x}_{m_s} \partial {\bf x}_{n_t}}
\neq
\frac{\partial^2 \theta}{\partial {\bf x}_{n_t} \partial {\bf x}_{m_s}}
$ in general.

5.2 Baraff & Witkin's Errors

I believe that there is a very small error in equation (14) of Baraff & Witkin's paper: the $ {\bf z}$ term should be scaled by $ h$ .

There is an error in their definition of $ \frac{\partial C}{\partial t}
$ , just above equation (11). They define it as

$\displaystyle \frac{\partial \bf C}{\partial t}
= \left(
\frac{\partial \bf C}{\partial {\bf x}}
\right)^T
\frac{\partial {\bf x}}{\partial t}
$

However, the condition function $ {\bf C}$ is a function of the position of several particles $ {\bf x}$ , and the paper does not specify which particle to choose. For my early implementations, I defined a different $ \frac{\partial \bf C}{\partial t}
$ for each particle, using

$\displaystyle \frac{\partial {\bf C}_m}{\partial t}
= \left(
\frac{\partial \bf C}{\partial {\bf x}_m}
\right)^T
\frac{\partial {\bf x}_m}{\partial t}
. $

However, this yielded incorrect results, especially when calculating the damping forces for the bend condition, resulting in frequent instability. Later, I realised that correct application of the chain rule should yield a single $ \frac{\partial \bf C}{\partial t}
$ for all particles, of the form

$\displaystyle \frac{\partial \bf C}{\partial t} = \sum_m\left( \frac{\partial \bf C}{\partial {\bf x}_m} \right)^T \frac{\partial {\bf x}_m}{\partial t} .$ (58)

The sum should be over the particles that influence $ {\bf C}$ . Visually, this yields vastly better results.

The final error in their paper is related to scale-invariance. Ideally, the parameters used for the simulation should be independent of the tesselation of the surface. For example, if you run the simulation with a $ 10\times10$ mesh and a $ 20\times20$ mesh and the same parameters, it should look basically the same. However, using Baraff & Witkin's choice of $ \alpha=a$ , this does not occur. I looked at the math for the specific case where the number of particles is doubled in $ u$ and $ v$ (e.g., from $ 10\times10$ to $ 20\times20$ ). In this case, the gravity force on each original particle decreases by a factor of four (since the mass of the surrounding triangles decreases by four). However, the (strong) stretch and shear forces decrease by a factor of eight. These forces are responsible for most of the resistance against gravity, and consequently the cloth sags substantially as the particle density is increased.

However, by using $ \alpha=a^\frac{3}{4}$ , the stretch and shear forces also decrease by a factor of four, as expected. The formula is not as intuitively obvious as $ \alpha=a$ , and I have not done tests with irregularly triangulated meshes, but it does work much better for regularly triangulated meshes.

5.3 Unit Magnitude Approximation

During my original development, I chased down one wrong alley while looking for the error in my (and Macri's) derivations. I was highly suspicious of one of Baraff & Witkin's approximations, where they assume that vectors' magnitudes are constant. This occurs in both the shear condition derivation and the bend condition derivation. I went through and rederived all of the formulas without this assumption, and obtained the formulas given in the appendix. After all of this work, there was still a problem, which proved to be the error in Macri's versions of equations (54) and (57).

After finding this error in Macri's work, I returned to the unit magnitude issue. I compared the results of my simulation using the formulas given in the body of the paper (using Baraff & Witkin's approximation) to the results using the formulas given in the appendix (without the approximation). In my test case, I found that the approximation gave more pleasing results! In total, stretch energy was halved, and shear and bend energy dropped by a small amount. The formulas for both stretch and bend energy are unchanged between the two cases, so this is a valid comparison of the energy in the cloth. The formula for shear energy is slightly changed by removing the unit magnitude approximation, however, so comparisons of energy aren't very meaningful.

To be honest, I was surprised that such a drastic change to the formulas had a relatively small effect on the final result. I suspect that there may be a lot of room for optimisation of Baraff & Witkin's system, achieving comparable results at less computational cost.

In the interests of presenting a direct implementation of Baraff & Witkin's paper, and on the basis of the better results, I have therefore presented the formulas with the constant magnitude approximation.

5.4 Parameters

For parameters, I adopted values that gave good results. I looked at Alias $ \vert$ Wavefront's Maya cloth software, but I suspect that they scale their parameters internally by an unknown amount. For damping forces, I multiplied the associated regular force's constant by the damping constant (e.g. $ k_{stretch} k_{damp}$ was used to damp stretch forces).


Table 1: Parameters used for simulation.
Name Symbol Value
Stretch force strength $ k_{stretch}$ $ 5.0 \times 10^3$
Shear force strength $ k_{shear}$ $ 0.5 \times 10^3$
Bend force strength ($ u$ ) $ k_{bend_u}$ $ 0.01 \times 10^{-3}$
Bend force strength ($ v$ ) $ k_{bend_v}$ $ 0.01 \times 10^{-3}$
Damping force strength $ k_{damp}$ 0.2
Rest stretch ($ u$ ) $ b_u$ 1
Rest stretch ($ v$ ) $ b_v$ 1
Time step $ h$ 0.02
Density $ \rho$ 0.1
Gravity $ g$ 9.81