# 3.9.5: Detect Collisions

![Fig. 3.9.5.1: A Karamba3D model collides with a mesh](/files/-MCkEUsOJfMHj5nJfkyt)

In connection with the optimization of structures there is often the need to define volumes where there should be no structure (e.g. windows, rooms). One approach is to choose the parametrization in such a way, that the volumes that should stay free can not be crossed by structure. This is often rather hard to achieve. Another method consists of using penalty functions: The parametrization does not preclude “wrong” solutions, but makes them perform worse than the “right” ones. This is where the **“Detect Collision”**-component comes into play. It takes a model and a mesh as input and determines the number of collisions between model and mesh. The result is returned in **“nColl”** (see fig. 3.9.5.1). The input-plug **“StartInd”** accepts the index of the element with which the collision detection should start. By default all elements of the model are included.

{% file src="/files/8xY3RcDvbpojbHIlEo3B" %}

{% file src="/files/TYrUA3FnV01XIjRCmCOH" %}


---

# 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.karamba3d.com/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.
