docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录 - 重命名 index.md 为 main.md - 修正所有模块文档中的错误: - math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式 - containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节 - core: 修复 types 链接错误 - debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI - memory: 修复头文件路径, malloc vs operator new, 新增方法文档 - resources: 修复 Shader/Texture 链接错误 - threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接 - 验证: fix_links.py 确认 0 个断裂引用
This commit is contained in:
23
docs/api/math/vector2/cross.md
Normal file
23
docs/api/math/vector2/cross.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Vector2::Cross
|
||||
|
||||
```cpp
|
||||
static float Cross(const Vector2& a, const Vector2& b)
|
||||
```
|
||||
|
||||
计算两个 2D 向量的叉积(返回标量)。结果为正值表示 b 在 a 的逆时针方向。
|
||||
|
||||
**参数:**
|
||||
- `a` - 第一个向量
|
||||
- `b` - 第二个向量
|
||||
|
||||
**返回:** `float` - 叉积结果 a.x * b.y - a.y * b.x
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 a(1.0f, 0.0f);
|
||||
Vector2 b(0.0f, 1.0f);
|
||||
float cross = Vector2::Cross(a, b); // 1.0f (逆时针)
|
||||
```
|
||||
23
docs/api/math/vector2/dot.md
Normal file
23
docs/api/math/vector2/dot.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Vector2::Dot
|
||||
|
||||
```cpp
|
||||
static float Dot(const Vector2& a, const Vector2& b)
|
||||
```
|
||||
|
||||
计算两个 2D 向量的点积。
|
||||
|
||||
**参数:**
|
||||
- `a` - 第一个向量
|
||||
- `b` - 第二个向量
|
||||
|
||||
**返回:** `float` - 点积结果 a.x * b.x + a.y * b.y
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 a(1.0f, 0.0f);
|
||||
Vector2 b(0.0f, 1.0f);
|
||||
float dot = Vector2::Dot(a, b); // 0.0f
|
||||
```
|
||||
17
docs/api/math/vector2/down.md
Normal file
17
docs/api/math/vector2/down.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Vector2::Down
|
||||
|
||||
```cpp
|
||||
static Vector2 Down()
|
||||
```
|
||||
|
||||
返回下方向向量 (0, -1)。
|
||||
|
||||
**返回:** `Vector2` - 值为 (0, -1) 的向量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 down = Vector2::Down();
|
||||
```
|
||||
17
docs/api/math/vector2/left.md
Normal file
17
docs/api/math/vector2/left.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Vector2::Left
|
||||
|
||||
```cpp
|
||||
static Vector2 Left()
|
||||
```
|
||||
|
||||
返回左方向向量 (-1, 0)。
|
||||
|
||||
**返回:** `Vector2` - 值为 (-1, 0) 的向量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 left = Vector2::Left();
|
||||
```
|
||||
24
docs/api/math/vector2/lerp.md
Normal file
24
docs/api/math/vector2/lerp.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Vector2::Lerp
|
||||
|
||||
```cpp
|
||||
static Vector2 Lerp(const Vector2& a, const Vector2& b, float t)
|
||||
```
|
||||
|
||||
在线性插值两个向量之间。参数 t 会在 [0, 1] 范围内被限制。
|
||||
|
||||
**参数:**
|
||||
- `a` - 起始向量
|
||||
- `b` - 结束向量
|
||||
- `t` - 插值因子,0 返回 a,1 返回 b
|
||||
|
||||
**返回:** `Vector2` - 插值结果
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 start(0.0f, 0.0f);
|
||||
Vector2 end(10.0f, 10.0f);
|
||||
Vector2 mid = Vector2::Lerp(start, end, 0.5f); // (5.0f, 5.0f)
|
||||
```
|
||||
25
docs/api/math/vector2/magnitude.md
Normal file
25
docs/api/math/vector2/magnitude.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Vector2::Magnitude
|
||||
|
||||
```cpp
|
||||
static float Magnitude(const Vector2& v)
|
||||
float Magnitude() const
|
||||
```
|
||||
|
||||
计算向量的长度(欧几里得范数)。
|
||||
|
||||
**静态版本参数:**
|
||||
- `v` - 要计算长度的向量
|
||||
|
||||
**实例版本:** 计算当前向量的长度。
|
||||
|
||||
**返回:** `float` - 向量长度 sqrt(x * x + y * y)
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 v(3.0f, 4.0f);
|
||||
float len = v.Magnitude(); // 5.0f
|
||||
float len2 = Vector2::Magnitude(v); // 5.0f
|
||||
```
|
||||
24
docs/api/math/vector2/movetowards.md
Normal file
24
docs/api/math/vector2/movetowards.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Vector2::MoveTowards
|
||||
|
||||
```cpp
|
||||
static Vector2 MoveTowards(const Vector2& current, const Vector2& target, float maxDistance)
|
||||
```
|
||||
|
||||
将当前向量朝目标向量移动指定距离。如果距离已小于 maxDistance,则直接返回目标。
|
||||
|
||||
**参数:**
|
||||
- `current` - 当前向量
|
||||
- `target` - 目标向量
|
||||
- `maxDistance` - 最大移动距离
|
||||
|
||||
**返回:** `Vector2` - 移动后的位置
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 current(0.0f, 0.0f);
|
||||
Vector2 target(10.0f, 0.0f);
|
||||
Vector2 moved = Vector2::MoveTowards(current, target, 3.0f); // (3.0f, 0.0f)
|
||||
```
|
||||
20
docs/api/math/vector2/normalize.md
Normal file
20
docs/api/math/vector2/normalize.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Vector2::Normalize
|
||||
|
||||
```cpp
|
||||
static Vector2 Normalize(const Vector2& v)
|
||||
```
|
||||
|
||||
将向量归一化为单位长度。如果向量长度接近零,返回零向量。
|
||||
|
||||
**参数:**
|
||||
- `v` - 要归一化的向量
|
||||
|
||||
**返回:** `Vector2` - 归一化后的单位向量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 dir = Vector2::Normalize(Vector2(3.0f, 4.0f)); // (0.6f, 0.8f)
|
||||
```
|
||||
18
docs/api/math/vector2/normalized.md
Normal file
18
docs/api/math/vector2/normalized.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Vector2::Normalized
|
||||
|
||||
```cpp
|
||||
Vector2 Normalized() const
|
||||
```
|
||||
|
||||
返回当前向量的归一化副本(单位长度)。不修改原向量。
|
||||
|
||||
**返回:** `Vector2` - 归一化后的向量副本
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 v(3.0f, 4.0f);
|
||||
Vector2 unit = v.Normalized(); // (0.6f, 0.8f), v 保持不变
|
||||
```
|
||||
17
docs/api/math/vector2/one.md
Normal file
17
docs/api/math/vector2/one.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Vector2::One
|
||||
|
||||
```cpp
|
||||
static Vector2 One()
|
||||
```
|
||||
|
||||
返回单位向量 (1, 1)。
|
||||
|
||||
**返回:** `Vector2` - 值为 (1, 1) 的向量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 unit = Vector2::One();
|
||||
```
|
||||
17
docs/api/math/vector2/right.md
Normal file
17
docs/api/math/vector2/right.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Vector2::Right
|
||||
|
||||
```cpp
|
||||
static Vector2 Right()
|
||||
```
|
||||
|
||||
返回右方向向量 (1, 0)。
|
||||
|
||||
**返回:** `Vector2` - 值为 (1, 0) 的向量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 right = Vector2::Right();
|
||||
```
|
||||
25
docs/api/math/vector2/sqrmagnitude.md
Normal file
25
docs/api/math/vector2/sqrmagnitude.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Vector2::SqrMagnitude
|
||||
|
||||
```cpp
|
||||
static float SqrMagnitude(const Vector2& v)
|
||||
float SqrMagnitude() const
|
||||
```
|
||||
|
||||
计算向量长度的平方。比 Magnitude 更快,避免了开方运算。
|
||||
|
||||
**静态版本参数:**
|
||||
- `v` - 要计算长度的向量
|
||||
|
||||
**实例版本:** 计算当前向量的长度平方。
|
||||
|
||||
**返回:** `float` - 向量长度平方 x * x + y * y
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 v(3.0f, 4.0f);
|
||||
float sqlen = v.SqrMagnitude(); // 25.0f
|
||||
float sqlen2 = Vector2::SqrMagnitude(v); // 25.0f
|
||||
```
|
||||
17
docs/api/math/vector2/up.md
Normal file
17
docs/api/math/vector2/up.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Vector2::Up
|
||||
|
||||
```cpp
|
||||
static Vector2 Up()
|
||||
```
|
||||
|
||||
返回上方向向量 (0, 1)。
|
||||
|
||||
**返回:** `Vector2` - 值为 (0, 1) 的向量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 up = Vector2::Up();
|
||||
```
|
||||
57
docs/api/math/vector2/vector2.md
Normal file
57
docs/api/math/vector2/vector2.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Vector2
|
||||
|
||||
2D 向量结构体,用于表示 2D 空间中的点、方向或颜色。
|
||||
|
||||
**头文件:** `#include <XCEngine/Math/Vector2.h>`
|
||||
|
||||
**命名空间:** `XCEngine::Math`
|
||||
|
||||
## 结构体定义
|
||||
|
||||
```cpp
|
||||
struct Vector2 {
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
};
|
||||
```
|
||||
|
||||
## 静态工厂方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| [Zero()](zero.md) | `Vector2` | 返回 (0, 0) |
|
||||
| [One()](one.md) | `Vector2` | 返回 (1, 1) |
|
||||
| [Up()](up.md) | `Vector2` | 返回 (0, 1),上方向 |
|
||||
| [Down()](down.md) | `Vector2` | 返回 (0, -1),下方向 |
|
||||
| [Right()](right.md) | `Vector2` | 返回 (1, 0),右方向 |
|
||||
| [Left()](left.md) | `Vector2` | 返回 (-1, 0),左方向 |
|
||||
|
||||
## 静态数学方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| [Dot(a, b)](dot.md) | `float` | 点积 |
|
||||
| [Cross(a, b)](cross.md) | `float` | 2D 叉积(返回标量) |
|
||||
| [Normalize(v)](normalize.md) | `Vector2` | 归一化向量 |
|
||||
| [Magnitude(v)](magnitude.md) | `float` | 向量长度 |
|
||||
| [SqrMagnitude(v)](sqrmagnitude.md) | `float` | 长度平方(更快) |
|
||||
| [Lerp(a, b, t)](lerp.md) | `Vector2` | 线性插值 |
|
||||
| [MoveTowards(current, target, maxDistance)](movetowards.md) | `Vector2` | 朝目标移动 |
|
||||
|
||||
## 实例方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| [Magnitude()](magnitude.md) | `float` | 获取向量长度 |
|
||||
| [SqrMagnitude()](sqrmagnitude.md) | `float` | 获取长度平方 |
|
||||
| [Normalized()](normalized.md) | `Vector2` | 获取归一化副本 |
|
||||
|
||||
## 运算符
|
||||
|
||||
- 算术: `+`, `-`, `*` (scalar), `/` (scalar)
|
||||
- 复合赋值: `+=`, `-=`, `*=`, `/=`
|
||||
- 比较: `==`, `!=`
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Math 模块总览](../math.md) - 返回 Math 模块总览
|
||||
17
docs/api/math/vector2/zero.md
Normal file
17
docs/api/math/vector2/zero.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Vector2::Zero
|
||||
|
||||
```cpp
|
||||
static Vector2 Zero()
|
||||
```
|
||||
|
||||
返回零向量 (0, 0)。
|
||||
|
||||
**返回:** `Vector2` - 值为 (0, 0) 的向量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Vector2 origin = Vector2::Zero();
|
||||
```
|
||||
Reference in New Issue
Block a user