# 3.8.5: 碰撞检测 (Detect Collisions)

![图3.8.5.1：Karamba3D模型与网格的碰撞](/files/-M9XuVuoS34YvdjPd2iv)

与结构优化相关，我们经常需要在不该有结构（例如：窗户、房间）的地方定义空间体积。一种方法是以确保空间体积不会与结构交叉的方式选择参数化。这通常很难实现。另一种方法是使用惩罚函数：参数化不排&#x9664;**“wrong（错误）”**&#x7684;解决方案，但使它们的性能比“**right（正确）”**&#x7684;解决方案差。这就&#x662F;**“Detect Collision（检测碰撞）”**&#x8FD0;算器发挥其作用的地方。它分别以模型和网格作为输入，并确定模型与网格之间的碰撞次数。其结果&#x4EE5;**“nColl”**&#x5F62;式反馈（如图3.8.5.1）。输入端&#x53E3;**“StartInd”**&#x63A5;受碰撞检测应从其开始的元素索引。默认情况下，包括模型的所有元素。


---

# 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://manual-1-3.karamba3d.com/chinese_1_3_3/3-in-depth-component-reference/3.8-utilities/3.8.5-detect-collisions.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.
