Files
XCEngine/docs/api/math/obb/intersects-obb.md

35 lines
708 B
Markdown
Raw Normal View History

2026-03-20 02:35:15 +08:00
# OBB::Intersects (OBB)
```cpp
bool Intersects(const OBB& other) const;
```
检测该 OBB 与另一个 OBB 是否相交。采用分离轴定理SAT进行检测通过测试 15 条可能的分离轴来判断两个盒子是否重叠。
**参数:**
- `other` - 另一个 OBB 包围盒
**返回:** 两 OBB 相交返回 `true`,否则返回 `false`
**异常:** 无
**线程安全:** ✅
**复杂度:** O(1)
**示例:**
```cpp
#include "AABB.h"
#include "Vector3.h"
#include "Matrix4.h"
using namespace XCEngine::Math;
OBB obb1(Vector3(0.0f, 0.0f, 0.0f), Vector3(1.0f, 0.5f, 1.0f));
OBB obb2(Vector3(1.5f, 0.0f, 0.0f), Vector3(1.0f, 0.5f, 1.0f));
if (obb1.Intersects(obb2)) {
}
```