Files
XCEngine/docs/api/math/matrix4/translation.md

35 lines
725 B
Markdown
Raw Normal View History

2026-03-20 02:35:15 +08:00
# Matrix4x4::Translation
```cpp
2026-03-20 02:35:15 +08:00
static Matrix4x4 Translation(const Vector3& v)
```
2026-03-20 02:35:15 +08:00
创建平移矩阵。生成的矩阵用于沿指定方向移动点或向量。
**参数:**
2026-03-20 02:35:15 +08:00
- `v` - 平移向量 (x, y, z 方向上的平移量)
2026-03-20 02:35:15 +08:00
**返回:** 平移矩阵
**线程安全:** ✅
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Core/Math/Matrix4.h"
#include "XCEngine/Core/Math/Vector3.h"
2026-03-20 02:35:15 +08:00
using namespace XCEngine::Math;
Matrix4 translate = Matrix4::Translation(Vector3(5.0f, 3.0f, 2.0f));
Vector3 point(1.0f, 1.0f, 1.0f);
Vector3 moved = translate.MultiplyPoint(point);
// moved = (6.0f, 4.0f, 3.0f)
```
2026-03-20 02:35:15 +08:00
## 相关文档
- [Matrix4](matrix4.md) - 返回类总览
- [TRS](trs.md) - 组合变换矩阵