docs: update math API docs
This commit is contained in:
@@ -4,17 +4,33 @@
|
||||
bool Intersects(const Bounds& other) const
|
||||
```
|
||||
|
||||
检测两个 Bounds 是否相交。
|
||||
检测该包围盒与另一个 Bounds 是否相交(重叠)。使用简化的 AABB 重叠检测算法,通过比较两个包围盒中心距离与它们 extents 之和来判断是否相交。
|
||||
|
||||
**参数:**
|
||||
- `other` - 另一个 Bounds
|
||||
|
||||
**返回:** `bool` - true 表示相交
|
||||
**返回:** `bool` - true 表示两个 Bounds 相交
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
if (bounds.Intersects(other)) { /* collision */ }
|
||||
#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
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Bounds](bounds.md) - 返回类总览
|
||||
- [Contains](contains.md) - 检测点是否在盒内
|
||||
|
||||
Reference in New Issue
Block a user