docs: update math API docs
This commit is contained in:
28
docs/api/math/vector4/operator-brackets.md
Normal file
28
docs/api/math/vector4/operator-brackets.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Vector4::operator[]
|
||||
|
||||
```cpp
|
||||
float operator[](int index) const
|
||||
float& operator[](int index)
|
||||
```
|
||||
|
||||
通过下标访问向量分量。
|
||||
|
||||
**参数:**
|
||||
- `index` - 分量索引 (0=x, 1=y, 2=z, 3=w)
|
||||
|
||||
**返回:** `float` 或 `float&` - 对应分量的值(常量版本返回值,左值版本返回引用)
|
||||
|
||||
**注意事项:** 未进行边界检查。index 应在 [0, 3] 范围内。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector4 v(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
float x = v[0]; // 1.0f
|
||||
float w = v[3]; // 4.0f
|
||||
v[1] = 5.0f; // v 变为 (1, 5, 3, 4)
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Vector4 总览](vector4.md) - 返回类总览
|
||||
Reference in New Issue
Block a user