35 lines
715 B
Markdown
35 lines
715 B
Markdown
# Matrix4x4::Translation
|
|
|
|
```cpp
|
|
static Matrix4x4 Translation(const Vector3& v)
|
|
```
|
|
|
|
创建平移矩阵。生成的矩阵用于沿指定方向移动点或向量。
|
|
|
|
**参数:**
|
|
- `v` - 平移向量 (x, y, z 方向上的平移量)
|
|
|
|
**返回:** 平移矩阵
|
|
|
|
**线程安全:** ✅
|
|
|
|
**复杂度:** O(1)
|
|
|
|
**示例:**
|
|
|
|
```cpp
|
|
#include "XCEngine/Math/Matrix4.h"
|
|
#include "XCEngine/Math/Vector3.h"
|
|
|
|
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)
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [Matrix4](matrix4.md) - 返回类总览
|
|
- [TRS](trs.md) - 组合变换矩阵 |