Cloth
Particle Cloths§
We can represent a cloth using a particle lattice connected via prismatic springs – springs which have nonzero rest-length.
The manner in which we connect the particles affects the material properties of the cloth.
Particle Connection
One way to connect the particles is to add a spring between for each neighbour of a particle. Then using bending springs to connect a particle with a particle two rows or columns over in the lattice.
Let:
- $\ell = \|\Delta \vec{x}\|_2$ be the current length of a spring.
- $L$ be the rest length, which are constant throughout simulation.
- $\vec{f}_0 = E (\ell - L) \frac{\Delta \vec{x}}{l}$ be the spring force, where $E$ is the stiffness constant.
- If $\ell = L,$ no deformation; no force.
- If $\ell > L,$ spring is stretched; attractive force.
- If $\ell < L,$ spring is compressed; repulsive force.
Examples§
Velocity Update on a 2-particle Cloth
Based on the cloth in Fig. 2.
Symplectic Euler: $$ \begin{align*} \mathfrak{M}v^{(k + 1)} &= \mathfrak{M} v^{(k)} + hf^{(k)}\\ \begin{pmatrix} M_0 & 0\\ 0 & M_1 \end{pmatrix} \begin{pmatrix} v_0^{(k + 1)}\\ v_1^{(k + 1)} \end{pmatrix} &= \begin{pmatrix} M_0 & 0\\ 0 & M_1 \end{pmatrix} \begin{pmatrix} v_0^{(k)}\\ v_1^{(k)} \end{pmatrix} + h \begin{pmatrix} \phantom{-}E\left(\frac{\ell - L}{\ell}\right)\Delta x^{(k)}\\ -E\left(\frac{\ell - L}{\ell}\right)\Delta x^{(k)} \end{pmatrix} \end{align*} $$
Implicit Euler:
$$ \begin{align*} (\mathfrak{M} - h^2 \mathfrak{K}) v^{(k + 1)} &= \mathfrak{M}v^{(k)} + hf^{(k)}\\ \mathfrak{K} &= \frac{\mathrm{d}f}{\mathrm{d}x}\\ &= \frac{\mathrm{d}}{\mathrm{d}x} \begin{pmatrix} \phantom{-}E\left(\frac{\ell - L}{\ell}\right)\Delta x^{(k)}\\ -E\left(\frac{\ell - L}{\ell}\right)\Delta x^{(k)} \end{pmatrix}\\ &= \frac{\mathrm{d}}{\mathrm{d}x} \left\{ E \frac{\ell - L}{\ell} \begin{pmatrix} -\mathbf{I}_3 & \phantom{-}\mathbf{I}_3\\ \phantom{-}\mathbf{I}_3 & -\mathbf{I}_3 \end{pmatrix} \begin{pmatrix} x_0\\ x_1 \end{pmatrix} \right\}\\ &= \begin{pmatrix} -k_s & \phantom{-}k_s\\ \phantom{-}k_s & -k_s \end{pmatrix}\\ k_s &= \frac{E}{\ell^2}\bigg(\frac{\ell - L}{\ell} \overbrace{\left(\Delta x^T \Delta x\right)}^{\textrm{inner product}} + \left(1 - \frac{\ell - L}{L}\right)\overbrace{\left(\Delta x \Delta x^T\right)}^{\textrm{outer product}}\bigg) \end{align*} $$
3 Particle Cloth
$$ \begin{align*} \htmlStyle{color: var(--red);}{f_{01}^{s}} &= E \frac{\ell_{01} - L_{01}}{\ell_{01}} \Delta x_{01}, \Delta x_{01} = x_1 - x_0\\ \htmlStyle{color: var(--green);}{f_{12}^{s}} &= E \frac{\ell_{12} - L_{12}}{\ell_{12}} \Delta x_{12}, \Delta x_{12} = x_2 - x_1 \end{align*} $$
Remember that we have equal and opposite forces: $\htmlStyle{color: var(--red);}{f_{01}^{s}} = -\htmlStyle{color: var(--red);}{f_{10}^{s}}.$
Next we compute the total force acting upon each particle and combine it into the block vector $f,$
$$ \left. \begin{align*} f_0(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--red)}{f_{01}^s}\\ f_1(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--red)}{f_{10}^s}\\ f_1(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--green)}{f_{12}^s}\\ f_2(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--green)}{f_{21}^s} \end{align*} \right\}_{\mathbb{R}^{9 \times 1}}\mkern-24mu = f = \begin{pmatrix} m_1\,\vec{g} + \htmlStyle{color: var(--red)}{f_{01}^s}\phantom{-f_{00}^s}\\ m_2\,\vec{g} - \htmlStyle{color: var(--red)}{f_{01}^s} + \htmlStyle{color: var(--green)}{f_{12}^s}\\ m_3\,\vec{g} - \htmlStyle{color: var(--green)}{f_{12}^s}\phantom{-f_{00}^s} \end{pmatrix} = \begin{pmatrix} f_0 \\ f_1 \\ f_2 \end{pmatrix} $$
We compute $\mathfrak{K}$ as a block matrix by first defining
$$ \overbrace{K_{ij}^{s}}^{\mathbb{R}^{3 \times 3}} = \frac{E}{\ell^{2}_{ij}}\left(\frac{\ell_{ij} - L_{ij}}{\ell_{ij}} \Delta x_{ij}^T\Delta x_{ij}\mathbf{I}_3 + \left(1 - \frac{\ell_{ij} - L_{ij}}{\ell_{ij}}\right)\Delta x_{ij} \Delta x_{ij}^{T}\right), $$
then computing the total contributions by each spring
$$ \begin{align*} K_{00}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--red);}{K_{10}^{s}}\\ K_{01}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--red);}{K_{01}^{s}}\\ K_{10}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--red);}{K_{01}^{s}}\\ K_{11}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--red);}{K_{10}^{s}}\\ K_{11}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--green);}{K_{21}^{s}}\\ K_{12}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--green);}{K_{12}^{s}}\\ K_{21}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--green);}{K_{12}^{s}}\\ K_{22}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(--green);}{K_{21}^{s}}\\ \end{align*} $$
and writing the stiffness matrix as follows
$$ \begin{align*} \mathfrak{K} &= \begin{pmatrix} \htmlStyle{color: var(--red)}{K_{00}} & \htmlStyle{color: var(--red)}{K_{01}} & K_{02}\\ \htmlStyle{color: var(--red)}{K_{10}} & \htmlStyle{color: var(--orange)}{K_{11}} & \htmlStyle{color: var(--green)}{K_{12}}\\ K_{20} & \htmlStyle{color: var(--green)}{K_{21}} & \htmlStyle{color: var(--green)}{K_{22}} \end{pmatrix}_{\mathbb{R}^{9 \times 9}}\\ &= \begin{pmatrix} \htmlStyle{color: var(--red)}{-K_{01}^{s}} & \htmlStyle{color: var(--red)}{K_{01}^{s}} & \mathbf{0}\\ \htmlStyle{color: var(--red)}{K_{01}^{s}} & \htmlStyle{color: var(--red)}{-K_{01}^{s}} \htmlStyle{color: var(--green)}{-K_{12}^{s}} & \htmlStyle{color: var(--green)}{-K_{12}^{s}}\\ \mathbf{0} & \htmlStyle{color: var(--green)}{-K_{12}^{s}} & \htmlStyle{color: var(--green)}{K_{12}^{s}} \end{pmatrix} \end{align*} $$
Note that $K_{02} = K_{20} = \mathbf{0}$ because there are no springs directly connecting particles $x_0$ and $x_2$.
We define the mass and velocity block matrices as
$$ \begin{align*} \mathfrak{M} &= \begin{pmatrix} M_0 & 0 & 0\\ 0 & M_1 & 0\\ 0 & 0 & M_2\\ \end{pmatrix}_{\mathbb{R}^{9 \times 9}}\\ v^{(k + 1)} &= \begin{pmatrix} v_0^{(k + 1)}\\v_2^{(k + 1)}\\v_3^{(k + 1)} \end{pmatrix}_{\mathbb{R}^{9 \times 1}} \end{align*} $$
Finally, solve $Ax = b$ where $A = \mathfrak{M} - h^2 \mathfrak{K},$ and $b = \mathfrak{M}v^{(k)} + hf$.
3 Particles in a Triangle
The force vector is given by
$$ f = \begin{pmatrix} m_0\,\vec{g} + \htmlStyle{color: var(--red)}{f_{01}} - \htmlStyle{color: var(--blue)}{f_{20}}\\ m_1\,\vec{g} + \htmlStyle{color: var(--green)}{f_{12}} - \htmlStyle{color: var(--red)}{f_{01}}\\ m_2\,\vec{g} + \htmlStyle{color: var(--blue)}{f_{20}} - \htmlStyle{color: var(--green)}{f_{12}} \end{pmatrix}_{\mathbb{R}^{9 \times 1}} $$
and the stiffness matrix
$$ \mathfrak{K} = \begin{pmatrix} \htmlStyle{color: var(--red)}{-K_{01}}\htmlStyle{color: var(--blue)}{-K_{20}} & \htmlStyle{color: var(--red)}{K_{01}} & \htmlStyle{color: var(--blue)}{K_{20}}\\ \htmlStyle{color: var(--red)}{K_{01}} & \htmlStyle{color: var(--green)}{-K_{12}} \htmlStyle{color: var(--red)}{-K_{01}} & \htmlStyle{color: var(--green)}{K_{12}}\\ \htmlStyle{color: var(--blue)}{K_{20}} & \htmlStyle{color: var(--green)}{K_{12}} & \htmlStyle{color: var(--blue)}{-K_{20}} \htmlStyle{color: var(--green)}{-K_{12}} \end{pmatrix}_{\mathbb{R}^{9 \times 9}} $$
where $K_{ij}$ is again computed as the total contribution of $K^{s}$ on a particle.
Finally, we solve $Ax = b$ like in the previous example.
Fixed Particles§
Sometimes we may wish to fix particles such that they are not affected by forces, to do this we simply exclude them from the system $Ax = b.$