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,40 +1,64 @@
# Bounds
轴对齐包围盒 (AABB),中心-范围表示。
**命名空间**: `XCEngine::Math`
**头文件:** `#include <XCEngine/Math/Bounds.h>`
**类型**: `struct`
**命名空间:** `XCEngine::Math`
**头文件**: `XCEngine/Math/Bounds.h`
## 结构体定义
**描述**: 轴对齐包围盒,用于场景管理中的快速剔除
## 概述
Bounds 表示一个轴对齐包围盒AABB使用中心点 `center` 和范围 `extents` 定义。`extents` 是从中心到包围盒每个面的距离,因此实际尺寸为 `extents * 2`。常用于视锥剔除、碰撞检测和场景管理中的快速排除不可见物体。
## 结构体成员
| 成员 | 类型 | 描述 |
|------|------|------|
| `center` | `Vector3` | 包围盒中心点 |
| `extents` | `Vector3` | 从中心到每个面的距离(实际尺寸 = extents * 2 |
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Bounds`](bounds.constructors.md) | 构造函数 |
| [`GetMin`](getmin.md) | 获取包围盒最小点 |
| [`GetMax`](getmax.md) | 获取包围盒最大点 |
| [`SetMinMax`](setminmax.md) | 从最小/最大点设置包围盒 |
| [`Intersects`](intersects.md) | 检测与另一个 Bounds 是否相交 |
| [`Contains`](contains.md) | 检测点是否在盒内 |
| [`Encapsulate`](encapsulate.md) | 扩展包围盒以包含点或另一个 Bounds |
| [`Expand`](expand.md) | 扩展包围盒 |
| [`GetClosestPoint`](getclosestpoint.md) | 获取盒上最接近给定点的点 |
| [`GetVolume`](getvolume.md) | 计算包围盒体积 |
## 使用示例
```cpp
struct Bounds {
Vector3 center = Vector3::Zero();
Vector3 extents = Vector3::Zero();
};
#include <XCEngine/Math/Bounds.h>
#include <XCEngine/Math/Vector3.h>
using namespace XCEngine::Math;
Bounds bounds(Vector3(0.0f, 0.0f, 0.0f), Vector3(2.0f, 2.0f, 2.0f));
Vector3 min = bounds.GetMin();
Vector3 max = bounds.GetMax();
bounds.Expand(1.0f);
if (bounds.Contains(Vector3(0.0f, 0.0f, 0.0f))) {
// point is inside
}
Bounds other(Vector3(5.0f, 0.0f, 0.0f), Vector3(1.0f, 1.0f, 1.0f));
if (bounds.Intersects(other)) {
// bounds intersect
}
```
## 构造函数
- `Bounds()` - 默认构造
- `Bounds(const Vector3& center, const Vector3& size)` - 从中心和大小构造
## 实例方法
| 方法 | 返回值 | 描述 |
|------|--------|------|
| [GetMin()](getmin.md) | `Vector3` | 最小点 |
| [GetMax()](getmax.md) | 最大点 |
| [SetMinMax(min, max)](setminmax.md) | `void` | 从最小/最大点设置 |
| [Contains(point)](contains.md) | `bool` | 点是否在盒内 |
| [Intersects(other)](intersects.md) | `bool` | 与另一个 Bounds 相交 |
| [Encapsulate(point)](encapsulate.md) | `void` | 扩展包含点 |
| [Encapsulate(bounds)](encapsulate-bounds.md) | `void` | 扩展包含另一个 Bounds |
| [Expand(amount)](expand.md) | `void` | 扩展包围盒 |
| [GetClosestPoint(point)](getclosestpoint.md) | `Vector3` | 盒上最接近的点 |
| [GetVolume()](getvolume.md) | `float` | 体积 |
## 相关文档
- [Math 模块总览](../math.md) - 返回 Math 模块总览