Cloth

27 Oct 2022


§ 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.

FIXME: "Figure 1: An example of a particle cloth. Red springs indicate bending springs."

Let:

  • =Δx2\ell = \|\Delta \vec{x}\|_2 be the current length of a spring.
  • LL be the rest length, which are constant throughout simulation.
  • f0=E(L)Δxl\vec{f}_0 = E (\ell - L) \frac{\Delta \vec{x}}{l} be the spring force, where EE is the stiffness constant.
FIXME: "Figure 2: A 2-particle cloth. $\large \Delta x/\ell$ in green is the unit direction of the spring."
  • If =L,\ell = L, no deformation; no force.
  • If >L,\ell > L, spring is stretched; attractive force.
  • If <L,\ell < L, spring is compressed; repulsive force.

§ Examples

Velocity Update on a 2-particle Cloth

Based on the cloth in Fig. 2.

Symplectic Euler:

Mv(k+1)=Mv(k)+hf(k)(M000M1)(v0(k+1)v1(k+1))=(M000M1)(v0(k)v1(k))+h(E(L)Δx(k)E(L)Δx(k))\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:

(Mh2K)v(k+1)=Mv(k)+hf(k)K=dfdx=ddx(E(L)Δx(k)E(L)Δx(k))=ddx{EL(I3I3I3I3)(x0x1)}=(ksksksks)ks=E2(L(ΔxTΔx)inner product+(1LL)(ΔxΔxT)outer product)\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

FIXME: "Figure 3: A 3-particle cloth."

f01s=E01L0101Δx01,Δx01=x1x0f12s=E12L1212Δx12,Δx12=x2x1\begin{align*} \htmlStyle{color: var(\-\-bs\-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(\-\-bs\-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: f01s=f10s.\htmlStyle{color: var(\-\-bs\-red);}{f_{01}^{s}} = -\htmlStyle{color: var(\-\-bs\-red);}{f_{10}^{s}}.

Next we compute the total force acting upon each particle and combine it into the block vector f,f,

f0(x0,x1,x2)+=f01sf1(x0,x1,x2)+=f10sf1(x0,x1,x2)+=f12sf2(x0,x1,x2)+=f21s}R9×1=f=(m1g+f01sf00sm2gf01s+f12sm3gf12sf00s)=(f0f1f2)\left. \begin{align*} f_0(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-red)}{f_{01}^s}\\ f_1(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-red)}{f_{10}^s}\\ f_1(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-green)}{f_{12}^s}\\ f_2(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-green)}{f_{21}^s} \end{align*} \right\}_{\mathbb{R}^{9 \times 1}}\mkern-24mu = f = \begin{pmatrix} m_1\,\vec{g} + \htmlStyle{color: var(\-\-bs\-red)}{f_{01}^s}\phantom{-f_{00}^s}\\ m_2\,\vec{g} - \htmlStyle{color: var(\-\-bs\-red)}{f_{01}^s} + \htmlStyle{color: var(\-\-bs\-green)}{f_{12}^s}\\ m_3\,\vec{g} - \htmlStyle{color: var(\-\-bs\-green)}{f_{12}^s}\phantom{-f_{00}^s} \end{pmatrix} = \begin{pmatrix} f_0 \\ f_1 \\ f_2 \end{pmatrix}

We compute K\mathfrak{K} as a block matrix by first defining

KijsR3×3=Eij2(ijLijijΔxijTΔxijI3+(1ijLijij)ΔxijΔxijT),\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

K00(x0,x1,x2)+=K10sK01(x0,x1,x2)+=K01sK10(x0,x1,x2)+=K01sK11(x0,x1,x2)+=K10sK11(x0,x1,x2)+=K21sK12(x0,x1,x2)+=K12sK21(x0,x1,x2)+=K12sK22(x0,x1,x2)+=K21s\begin{align*} K_{00}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-red);}{K_{10}^{s}}\\ K_{01}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-red);}{K_{01}^{s}}\\ K_{10}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-red);}{K_{01}^{s}}\\ K_{11}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-red);}{K_{10}^{s}}\\ K_{11}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-green);}{K_{21}^{s}}\\ K_{12}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-green);}{K_{12}^{s}}\\ K_{21}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-green);}{K_{12}^{s}}\\ K_{22}(x_0, x_1, x_2) &\mathrel{+}= \htmlStyle{color: var(\-\-bs\-green);}{K_{21}^{s}}\\ \end{align*}

and writing the stiffness matrix as follows

K=(K00K01K02K10K11K12K20K21K22)R9×9=(K01sK01s0K01sK01sK12sK12s0K12sK12s)\begin{align*} \mathfrak{K} &= \begin{pmatrix} \htmlStyle{color: var(\-\-bs\-red)}{K_{00}} & \htmlStyle{color: var(\-\-bs\-red)}{K_{01}} & K_{02}\\ \htmlStyle{color: var(\-\-bs\-red)}{K_{10}} & \htmlStyle{color: var(\-\-bs\-orange)}{K_{11}} & \htmlStyle{color: var(\-\-bs\-green)}{K_{12}}\\ K_{20} & \htmlStyle{color: var(\-\-bs\-green)}{K_{21}} & \htmlStyle{color: var(\-\-bs\-green)}{K_{22}} \end{pmatrix}_{\mathbb{R}^{9 \times 9}}\\ &= \begin{pmatrix} \htmlStyle{color: var(\-\-bs\-red)}{-K_{01}^{s}} & \htmlStyle{color: var(\-\-bs\-red)}{K_{01}^{s}} & \mathbf{0}\\ \htmlStyle{color: var(\-\-bs\-red)}{K_{01}^{s}} & \htmlStyle{color: var(\-\-bs\-red)}{-K_{01}^{s}} \htmlStyle{color: var(\-\-bs\-green)}{-K_{12}^{s}} & \htmlStyle{color: var(\-\-bs\-green)}{-K_{12}^{s}}\\ \mathbf{0} & \htmlStyle{color: var(\-\-bs\-green)}{-K_{12}^{s}} & \htmlStyle{color: var(\-\-bs\-green)}{K_{12}^{s}} \end{pmatrix} \end{align*}

Note that K02=K20=0K_{02} = K_{20} = \mathbf{0} because there are no springs directly connecting particles x0x_0 and x2x_2.

We define the mass and velocity block matrices as

M=(M0000M1000M2)R9×9v(k+1)=(v0(k+1)v2(k+1)v3(k+1))R9×1\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=bAx = b where A=Mh2K,A = \mathfrak{M} - h^2 \mathfrak{K}, and b=Mv(k)+hfb = \mathfrak{M}v^{(k)} + hf.

3 Particles in a Triangle

FIXME: "Figure 4: A 3-particle cloth connected in a triangle."

The force vector is given by

f=(m0g+f01f20m1g+f12f01m2g+f20f12)R9×1f = \begin{pmatrix} m_0\,\vec{g} + \htmlStyle{color: var(\-\-bs\-red)}{f_{01}} - \htmlStyle{color: var(\-\-bs\-blue)}{f_{20}}\\ m_1\,\vec{g} + \htmlStyle{color: var(\-\-bs\-green)}{f_{12}} - \htmlStyle{color: var(\-\-bs\-red)}{f_{01}}\\ m_2\,\vec{g} + \htmlStyle{color: var(\-\-bs\-blue)}{f_{20}} - \htmlStyle{color: var(\-\-bs\-green)}{f_{12}} \end{pmatrix}_{\mathbb{R}^{9 \times 1}}

and the stiffness matrix

K=(K01K20K01K20K01K12K01K12K20K12K20K12)R9×9\mathfrak{K} = \begin{pmatrix} \htmlStyle{color: var(\-\-bs\-red)}{-K_{01}}\htmlStyle{color: var(\-\-bs\-blue)}{-K_{20}} & \htmlStyle{color: var(\-\-bs\-red)}{K_{01}} & \htmlStyle{color: var(\-\-bs\-blue)}{K_{20}}\\ \htmlStyle{color: var(\-\-bs\-red)}{K_{01}} & \htmlStyle{color: var(\-\-bs\-green)}{-K_{12}} \htmlStyle{color: var(\-\-bs\-red)}{-K_{01}} & \htmlStyle{color: var(\-\-bs\-green)}{K_{12}}\\ \htmlStyle{color: var(\-\-bs\-blue)}{K_{20}} & \htmlStyle{color: var(\-\-bs\-green)}{K_{12}} & \htmlStyle{color: var(\-\-bs\-blue)}{-K_{20}} \htmlStyle{color: var(\-\-bs\-green)}{-K_{12}} \end{pmatrix}_{\mathbb{R}^{9 \times 9}}

where KijK_{ij} is again computed as the total contribution of KsK^{s} on a particle.

Finally, we solve Ax=bAx = 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.Ax = b.