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

35 lines
649 B
Markdown
Raw Normal View History

2026-03-20 02:35:15 +08:00
# Matrix4x4::operator[]
```cpp
float* operator[](int row)
const float* operator[](int row) const
```
通过行索引访问矩阵元素。返回指向该行第一列元素的指针。
**参数:**
- `row` - 行索引0-3
**返回:** 指向该行数据的指针
**线程安全:** ✅
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Matrix4.h"
using namespace XCEngine::Math;
Matrix4 m = Matrix4::Identity();
m[0][0] = 5.0f; // 设置第一行第一列
m[1][2] = 3.0f; // 设置第二行第三列
float val = m[0][1]; // 读取第一行第二列
```
## 相关文档
- [Matrix4](matrix4.md) - 返回类总览