docs: update math API docs

This commit is contained in:
2026-03-20 02:35:15 +08:00
parent e165dbea1c
commit c5b17239ca
243 changed files with 5307 additions and 1327 deletions

View File

@@ -1,24 +1,34 @@
# Frustum::Contains (sphere)
# Frustum::Contains
```cpp
bool Contains(const Sphere& sphere) const
```
检测球体是否完全在视锥体内
检测球体是否完全位于视锥体内。判断方式为:依次计算球心到 6 个裁剪平面的有符号距离,若任意一个距离小于 `-radius`(即球心到平面的距离小于球半径的负数,说明球体完全在平面外侧),则视锥体不包含该球体
**参数:**
- `sphere` - 要检测的球体
- `sphere` - 要检测的球体,包含圆心 `center` 和半径 `radius`
**返回:** `bool` - 球体完全在视锥内返回 true
**返回:** `bool` - 球体完全在视锥内返回 `true`,否则返回 `false`
**复杂度** O(1)
**线程安全** ✅(只读操作,不修改状态)
**复杂度:** O(6),即遍历 6 个裁剪平面
**示例:**
```cpp
Frustum frustum = camera.CalculateFrustum();
Sphere collider = object.GetBoundingSphere();
if (frustum.Contains(collider)) {
// 球体完全在视锥内
#include <XCEngine/Math/Frustum.h>
#include <XCEngine/Math/Sphere.h>
void CheckSphereInFrustum(const Frustum& frustum, const Sphere& sphere) {
if (frustum.Contains(sphere)) {
// 球体完全在视锥内
}
}
```
## 相关文档
- [Frustum 总览](frustum.md) - 返回类总览
- [Intersects](intersects-sphere.md) - 球体与视锥相交检测