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

45 lines
1.1 KiB
Markdown
Raw Normal View History

2026-03-20 02:35:15 +08:00
# Matrix4x4::TRS
```cpp
2026-03-20 02:35:15 +08:00
static Matrix4x4 TRS(const Vector3& translation, const Quaternion& rotation, const Vector3& scale)
```
2026-03-20 02:35:15 +08:00
创建组合变换矩阵。等价于先缩放、再旋转、最后平移的组合效果。
**参数:**
- `translation` - 平移向量
- `rotation` - 旋转四元数
- `scale` - 缩放向量
2026-03-20 02:35:15 +08:00
**返回:** 组合变换矩阵 T * R * S
2026-03-20 02:35:15 +08:00
**线程安全:** ✅
**复杂度:** O(n²) - 涉及多次 4x4 矩阵运算
**示例:**
```cpp
#include "XCEngine/Core/Math/Matrix4.h"
#include "XCEngine/Core/Math/Vector3.h"
#include "XCEngine/Core/Math/Quaternion.h"
2026-03-20 02:35:15 +08:00
using namespace XCEngine::Math;
Matrix4 transform = Matrix4::TRS(
Vector3(1.0f, 2.0f, 3.0f),
Quaternion::FromEuler(0.0f, 90.0f, 0.0f),
Vector3(2.0f, 2.0f, 2.0f)
);
Vector3 point(1.0f, 0.0f, 0.0f);
Vector3 transformed = transform.MultiplyPoint(point);
```
2026-03-20 02:35:15 +08:00
## 相关文档
- [Matrix4](matrix4.md) - 返回类总览
- [Translation](translation.md) - 平移矩阵
- [Rotation](rotation.md) - 旋转矩阵
- [Scale](scale.md) - 缩放矩阵
- [Decompose](decompose.md) - 分解矩阵