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:
2026-03-19 00:22:30 +08:00
parent d0e16962c8
commit dc850d7739
1012 changed files with 26673 additions and 9222 deletions

View File

@@ -0,0 +1,20 @@
# Math::DEG_TO_RAD
```cpp
constexpr float DEG_TO_RAD = Math::PI / 180.0f;
```
`DEG_TO_RAD` 是角度转弧度的转换系数。1 度等于 `PI / 180` 弧度,约等于 0.01745329251994329577。使用该常量将角度值乘以 `DEG_TO_RAD` 即可得到对应的弧度值。
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float angleDegrees = 90.0f;
float angleRadians = angleDegrees * Math::DEG_TO_RAD;
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览

View File

@@ -0,0 +1,20 @@
# Math::Degrees
```cpp
float Degrees(float radians);
```
`Degrees` 函数将弧度值转换为角度值。转换公式为:`角度 = 弧度 * (180 / PI)`。该函数是 `Radians` 函数的逆函数,常用于将三角函数的返回值或物理引擎中的弧度值转换为人机界面友好的角度值。
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float radians = Math::HALF_PI;
float degrees = Math::Degrees(radians);
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览

View File

@@ -0,0 +1,23 @@
# Math::EPSILON
```cpp
constexpr float EPSILON = 1e-6f;
```
`EPSILON` 是一个非常小的浮点数常量,值为 0.000001。该常量主要用于浮点数比较,由于浮点数精度问题,直接使用 `==` 比较浮点数可能产生错误结果,此时应使用 `EPSILON` 进行容差比较。例如判断两个浮点数是否相等,可以检查它们的差的绝对值是否小于 `EPSILON`
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float a = 0.1f + 0.2f;
float b = 0.3f;
if (Math::Abs(a - b) < Math::EPSILON) {
// a 和 b 可以视为相等
}
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览

View File

@@ -0,0 +1,19 @@
# Math::FLOAT_MAX
```cpp
constexpr float FLOAT_MAX = 3.402823466e+38f;
```
`FLOAT_MAX` 是 IEEE 754 单精度浮点数能表示的最大正有限值,约为 3.402823466e+38。该常量常用于初始化变量为最大值、在搜索算法中作为上界、或在需要表示"无穷大"但又不想引入 `INFINITY` 的场景中使用。
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float maxDistance = Math::FLOAT_MAX;
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览

54
docs/api/math/h/h.md Normal file
View File

@@ -0,0 +1,54 @@
# Math
**命名空间**: `XCEngine::Math`
**类型**: `header`
**描述**: 数学库常量和辅助函数头文件。
## 概述
`Math.h` 提供了图形引擎常用的数学常量和辅助函数,包括圆周率、角度转换、浮点精度等基础常量,以及角度弧度转换等常用函数。
## 常量
| 常量 | 值 | 描述 |
|------|-----|------|
| [PI](pi.md) | 3.14159265358979323846f | 圆周率 |
| [TWO_PI](two-pi.md) | 6.28318530717958647692f | 2π |
| [HALF_PI](half-pi.md) | 1.57079632679489661923f | π/2 |
| [DEG_TO_RAD](deg-to-rad.md) | PI / 180.0f | 度到弧度 |
| [RAD_TO_DEG](rad-to-deg.md) | 180.0f / PI | 弧度到度 |
| [EPSILON](epsilon.md) | 1e-6f | 浮点精度 |
| [FLOAT_MAX](float-max.md) | 3.402823466e+38f | 浮点最大值 |
## 辅助函数
| 函数 | 描述 |
|------|------|
| [Radians](radians.md) | 度转弧度 |
| [Degrees](degrees.md) | 弧度转度 |
## 使用示例
```cpp
#include <XCEngine/Math/Math.h>
using namespace XCEngine::Math;
// 使用常量
float angle = 90.0f * DEG_TO_RAD; // 90度转弧度
// 使用函数
float rad = Radians(180.0f); // 180度 -> π 弧度
float deg = Degrees(Math::PI); // π 弧度 -> 180度
// 比较浮点数
if (fabsf(a - b) < EPSILON) {
// 认为 a 和 b 相等
}
```
## 相关文档
- [Math 模块总览](../math.md) - 返回 Math 模块总览

View File

@@ -0,0 +1,19 @@
# Math::HALF_PI
```cpp
constexpr float HALF_PI = 1.57079632679489661923f;
```
`HALF_PI` 是圆周率除以 2即 90 度对应的弧度值,约为 1.57079632679489661923。该常量常用于角度与弧度的转换、四分之一圆周计算等场景。
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float ninetyDegreesRadians = Math::HALF_PI;
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览

22
docs/api/math/h/pi.md Normal file
View File

@@ -0,0 +1,22 @@
# Math::PI
```cpp
constexpr float PI = 3.14159265358979323846f;
```
圆周率常量,精确到 float 能表示的最高精度。
**用途:** 用于三角函数计算、弧度角度转换、圆形/弧度相关计算。
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float circumference = 2.0f * Math::PI * radius;
float area = Math::PI * radius * radius;
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览

View File

@@ -0,0 +1,20 @@
# Math::RAD_TO_DEG
```cpp
constexpr float RAD_TO_DEG = 180.0f / Math::PI;
```
`RAD_TO_DEG` 是弧度转角度的转换系数。1 弧度等于 `180 / PI` 度,约等于 57.29577951308232087685。使用该常量将弧度值乘以 `RAD_TO_DEG` 即可得到对应的角度值。
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float radians = Math::HALF_PI;
float degrees = radians * Math::RAD_TO_DEG;
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览

View File

@@ -0,0 +1,20 @@
# Math::Radians
```cpp
float Radians(float degrees);
```
`Radians` 函数将角度值转换为弧度值。转换公式为:`弧度 = 角度 * (PI / 180)`。该函数是 `Degrees` 函数的逆函数,常用于将 UI 输入的角度值或游戏中的角度值转换为三角函数所需的弧度值。
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float degrees = 90.0f;
float radians = Math::Radians(degrees);
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览

19
docs/api/math/h/two-pi.md Normal file
View File

@@ -0,0 +1,19 @@
# Math::TWO_PI
```cpp
constexpr float TWO_PI = 6.28318530717958647692f;
```
`TWO_PI` 是圆周率的两倍,即完整的圆周长对应的弧度值,约为 6.28318530717958647692。该常量常用于需要完整圆周旋转的场景,例如角度归一化、三角函数周期计算、圆形运动等。
**示例:**
```cpp
#include <XCEngine/Math/Math.h>
float fullCircleRadians = Math::TWO_PI;
```
## 相关文档
- [Math 总览](h.md) - 返回 Math 概览