# 5.Cloth Simulation\_冲突文件\_zkx\_20240828215918

布料模拟 二维的面在三维中展开的状态

* A Mass-Spring System
  * Explicit Integration
  * Implicit Integration
* Bending and Locking Issues
* Shape matching

#### A Mass Spring System

弹簧质点系统

一个理想的弹簧， 胡克定律：试图恢复原状，拉的越长力越大 F = kx 拉越长能量越大

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081656755.png)

xi 的能量是各个弹簧的能量累加

![](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081702977.png)

#### Structured Spring Networks

结构化表示弹簧网络

假设衣物是结构化的

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081704368.png)

右边是更优化的，能够减少很多弹簧

不规则的弹簧连接

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081730710.png)

利用内部边的对角构建抗弯曲的弹簧

通过 Vertex list 和 Triangle list 信息生成弹簧

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081735325.png)

不能直接拿三角形边的信息，因为会有重复边

构建 Triple list，删除重复数据，用排序的方式删除 同时生成内部边的垂直弹簧

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081736237.png)

显示积分更新所有质点信息

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081806639.png)

显示积分的弊端 如果时间步长太大，第二次模拟质点会过远，并超过之前的绝对值

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081823120.png)

隐式积分 Implicit Integration

在当前时刻 f \[1] 是不知道的

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081835854.png)

holonomic 只和位置有关系的力 把 f 写成 f(x\_1)，不是线性的力

认为 x\[1] 是 F(x) 的最小值 ![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081846821.png)

这个隐式积分做法是把数值解转化为解析解，目标是求得 x\_1 ，认为在 x\_1 处，对于力的函数的求导为 0，也就是弹簧能够平衡的位置，以此来更新速度。

认为下一帧的 x 一定是受力平衡点，以此来求得能够达到目标点的速度。而不是显示积分，通过时间步长，由受力推出速度。

但是由一阶导数式反推出 F(x) 很难，这边是已经知道了

Newton-Raphson Method 牛顿法 数值解逼近目标值，利用一阶的泰勒展开

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081911816.png)

一阶导为 0 可能是最大值或最小值，此时看二阶导

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081935397.png)

只能找到局部最小值，local minimal ，没有什么好的方法找到全局最小值。 限定二阶导永远大于 0，可以限定只有一个最小值。

三维的牛顿法 ![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081951516.png)

用牛顿迭代法来求 x\_1

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306081956282.png)

非线性优化问题，各种解各种物理系统的核心

弹簧系统的 Hessian

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306082015661.png)

弹簧的 Hessian 矩阵是弹簧 F(x) 的二阶导

在拉伸的时候，它是正定的，表示其有唯一解

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306082013014.png)

挤压上不正定，可能有各种状态

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306082017005.png)

用 Jacobi 方法多次迭代

![image.png](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202306082024858.png)

Jacobi 可以用 GPU 加速


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://okzkx.gitbook.io/blogs/game-tech/engine/model/animation/games103-ji-yu-wu-li-de-ji-suan-ji-dong-hua-ru-men/5.cloth-simulation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
