Files
XCEngine/docs/api/math/obb/obb.md
ssdfasd 8df04c120f docs: 更新 API 文档 - 多模块修复和完善
- audio: 更新 audio-system 方法文档
- components: 新增 audio-listener/audio-source 组件方法文档,新增 remove-component 方法
- core: 更新 filewriter, types 文档
- math: 更新 box 方法文档
- memory: 更新 proxy-allocator 文档
- resources: 更新 loader 和 texture 文档
- rhi: 更新 opengl 设备、shader、swap-chain 文档
- threading: 更新 mutex 和 task-system 文档
2026-03-26 01:58:45 +08:00

53 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# OBB
**命名空间**: `XCEngine::Math`
**类型**: `struct`
**头文件**: `XCEngine/Math/AABB.h`
**描述**: 定向包围盒,支持任意方向旋转的盒状包围体
## 概述
OBBOriented Bounding Box是一种包围盒类型与轴对齐包围盒AABB不同OBB 可以任意旋转因此能够更紧凑地包围复杂形状的对象。OBB 由一个中心点、半长向量extents和一个变换矩阵组成变换矩阵定义了盒子的朝向。
OBB 常用于碰撞检测、剔除运算和物理模拟等场景。
## 公共方法
| 方法 | 描述 |
|------|------|
| [`GetAxis`](get-axis.md) | 获取指定索引处的局部轴方向 |
| [`GetMin`](get-min.md) | 获取包围盒最小顶点 |
| [`GetMax`](get-max.md) | 获取包围盒最大顶点 |
| [`Contains`](contains.md) | 检测点是否在包围盒内 |
| [`Intersects`](intersects-obb.md) | 检测与另一个 OBB 是否相交 |
| [`Intersects`](intersects-sphere.md) | 检测与球体是否相交 |
## 使用示例
```cpp
#include "AABB.h"
#include "Vector3.h"
#include "Matrix4.h"
using namespace XCEngine::Math;
OBB obb(Vector3(0.0f, 0.0f, 0.0f), Vector3(1.0f, 0.5f, 1.0f));
Vector3 point(0.5f, 0.25f, 0.5f);
if (obb.Contains(point)) {
}
Vector3 axis = obb.GetAxis(0);
Vector3 min = obb.GetMin();
Vector3 max = obb.GetMax();
```
## 相关文档
- [Vector3](../vector3/vector3.md) - 三维向量
- [Matrix4](../matrix4/matrix4.md) - 4x4 变换矩阵
- [Sphere](../sphere/sphere.md) - 球体