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

44 lines
999 B
Markdown
Raw Normal View History

2026-03-20 02:35:15 +08:00
# Matrix4x4::operator*
```cpp
Matrix4x4 operator*(const Matrix4x4& other) const
Vector4 operator*(const Vector4& v) const
```
两个重载分别用于矩阵与矩阵乘法,以及矩阵与四维向量的乘法。
**参数(矩阵乘法):**
- `other` - 右侧矩阵
**参数(向量乘法):**
- `v` - 四维向量
**返回:**
- 矩阵乘法:结果矩阵
- 向量乘法:变换后的四维向量
**线程安全:** ✅
**复杂度:** O(n²) - 矩阵乘法为 O(4³),向量乘法为 O(4)
**示例:**
```cpp
#include "XCEngine/Math/Matrix4.h"
#include "XCEngine/Math/Vector4.h"
using namespace XCEngine::Math;
Matrix4 m1 = Matrix4::RotationY(1.0f);
Matrix4 m2 = Matrix4::Translation(Vector3(1.0f, 0.0f, 0.0f));
Matrix4 combined = m1 * m2;
Vector4 v(1.0f, 0.0f, 0.0f, 1.0f);
Vector4 transformed = m1 * v;
```
## 相关文档
- [Matrix4](matrix4.md) - 返回类总览
- [MultiplyPoint](multiplypoint.md) - 点变换
- [MultiplyVector](multiplyvector.md) - 向量变换