refactor: reorganize docs into plan/ and add skills/
This commit is contained in:
62
docs/api/math/math-vector4.md
Normal file
62
docs/api/math/math-vector4.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# Vector4
|
||||
|
||||
4D 向量结构体,用于表示齐次坐标、颜色 (RGBA) 或 SIMD 操作。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Vector4.h>
|
||||
```
|
||||
|
||||
## 命名空间
|
||||
|
||||
`XCEngine::Math`
|
||||
|
||||
## 结构体定义
|
||||
|
||||
```cpp
|
||||
struct Vector4 {
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
float w = 0.0f;
|
||||
};
|
||||
```
|
||||
|
||||
## 构造方法
|
||||
|
||||
- `Vector4(float x, float y, float z, float w)` - 从四个分量构造
|
||||
- `explicit Vector4(const Vector3& v, float w = 0.0f)` - 从 Vector3 构造
|
||||
|
||||
## 静态工厂方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| `Zero()` | `Vector4` | 返回 (0, 0, 0, 0) |
|
||||
| `One()` | `Vector4` | 返回 (1, 1, 1, 1) |
|
||||
|
||||
## 静态数学方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| `Dot(a, b)` | `float` | 4D 点积 |
|
||||
| `Project(vector, onNormal)` | `Vector4` | 投影 |
|
||||
|
||||
## 实例方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| `ToVector3()` | `Vector3` | 转换到 Vector3(丢弃 w) |
|
||||
|
||||
## 运算符
|
||||
|
||||
- 算术: `+`, `-`, `*` (scalar)
|
||||
- 下标: `operator[]`
|
||||
- 比较: `==`, `!=`
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
Vector4 pos4(1.0f, 2.0f, 3.0f, 1.0f);
|
||||
Vector3 pos3 = pos4.ToVector3();
|
||||
```
|
||||
Reference in New Issue
Block a user