Files
XCEngine/docs/api/math/bounds/intersects.md

37 lines
837 B
Markdown
Raw Normal View History

# Bounds::Intersects
```cpp
bool Intersects(const Bounds& other) const
```
2026-03-20 02:35:15 +08:00
检测该包围盒与另一个 Bounds 是否相交(重叠)。使用简化的 AABB 重叠检测算法,通过比较两个包围盒中心距离与它们 extents 之和来判断是否相交。
**参数:**
- `other` - 另一个 Bounds
2026-03-20 02:35:15 +08:00
**返回:** `bool` - true 表示两个 Bounds 相交
**线程安全:** ✅
**复杂度:** O(1)
**示例:**
```cpp
2026-03-20 02:35:15 +08:00
#include <XCEngine/Math/Bounds.h>
#include <XCEngine/Math/Vector3.h>
using namespace XCEngine::Math;
Bounds a(Vector3(0.0f, 0.0f, 0.0f), Vector3(2.0f, 2.0f, 2.0f));
Bounds b(Vector3(1.0f, 0.0f, 0.0f), Vector3(2.0f, 2.0f, 2.0f));
if (a.Intersects(b)) {
// a and b overlap
}
```
2026-03-20 02:35:15 +08:00
## 相关文档
- [Bounds](bounds.md) - 返回类总览
- [Contains](contains.md) - 检测点是否在盒内