Files
XCEngine/docs/api/math/obb/get-axis.md
2026-03-20 02:35:15 +08:00

34 lines
649 B
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::GetAxis
```cpp
Vector3 GetAxis(int index) const;
```
获取 OBB 在指定索引处的局部轴方向。index 取值为 0、1、2分别对应局部坐标系的 X、Y、Z 轴。
**参数:**
- `index` - 轴索引0=X轴1=Y轴2=Z轴
**返回:** 对应索引处的轴方向向量(已归一化)
**异常:**
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
#include "AABB.h"
#include "Vector3.h"
using namespace XCEngine::Math;
OBB obb(Vector3(0.0f, 0.0f, 0.0f), Vector3(1.0f, 0.5f, 1.0f));
Vector3 axisX = obb.GetAxis(0);
Vector3 axisY = obb.GetAxis(1);
Vector3 axisZ = obb.GetAxis(2);
```