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:
20
docs/api/math/quaternion/dot.md
Normal file
20
docs/api/math/quaternion/dot.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Quaternion::Dot
|
||||
|
||||
```cpp
|
||||
float Dot(const Quaternion& other) const
|
||||
```
|
||||
|
||||
计算两个四元数的点积。
|
||||
|
||||
**参数:**
|
||||
- `other` - 另一个四元数
|
||||
|
||||
**返回:** `float` - 点积结果
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
float dot = quat1.Dot(quat2);
|
||||
```
|
||||
21
docs/api/math/quaternion/fromaxisangle.md
Normal file
21
docs/api/math/quaternion/fromaxisangle.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Quaternion::FromAxisAngle
|
||||
|
||||
```cpp
|
||||
static Quaternion FromAxisAngle(const Vector3& axis, float radians)
|
||||
```
|
||||
|
||||
从轴角创建四元数。
|
||||
|
||||
**参数:**
|
||||
- `axis` - 旋转轴(应为单位向量)
|
||||
- `radians` - 旋转角度(弧度)
|
||||
|
||||
**返回:** `Quaternion` - 表示旋转的四元数
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion rot = Quaternion::FromAxisAngle(Vector3::Up(), 90.0f * DEG_TO_RAD);
|
||||
```
|
||||
25
docs/api/math/quaternion/fromeulerangles.md
Normal file
25
docs/api/math/quaternion/fromeulerangles.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Quaternion::FromEulerAngles
|
||||
|
||||
```cpp
|
||||
static Quaternion FromEulerAngles(float pitch, float yaw, float roll)
|
||||
static Quaternion FromEulerAngles(const Vector3& euler)
|
||||
```
|
||||
|
||||
从欧拉角创建四元数。角度以弧度为单位。
|
||||
|
||||
**参数:**
|
||||
- `pitch` - 俯仰角(X 轴旋转)
|
||||
- `yaw` - 偏航角(Y 轴旋转)
|
||||
- `roll` - 翻滚角(Z 轴旋转)
|
||||
- `euler` - 欧拉角向量 (pitch, yaw, roll)
|
||||
|
||||
**返回:** `Quaternion` - 表示旋转的四元数
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion rot = Quaternion::FromEulerAngles(0.0f, 90.0f * DEG_TO_RAD, 0.0f);
|
||||
Quaternion rot2 = Quaternion::FromEulerAngles(Vector3(0.0f, 90.0f * DEG_TO_RAD, 0.0f));
|
||||
```
|
||||
21
docs/api/math/quaternion/fromrotationmatrix.md
Normal file
21
docs/api/math/quaternion/fromrotationmatrix.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Quaternion::FromRotationMatrix
|
||||
|
||||
```cpp
|
||||
static Quaternion FromRotationMatrix(const Matrix4x4& matrix)
|
||||
```
|
||||
|
||||
从旋转矩阵创建四元数。
|
||||
|
||||
**参数:**
|
||||
- `matrix` - 旋转矩阵
|
||||
|
||||
**返回:** `Quaternion` - 表示相同旋转的四元数
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Matrix4 rotMat = Matrix4::RotationY(90.0f * DEG_TO_RAD);
|
||||
Quaternion quat = Quaternion::FromRotationMatrix(rotMat);
|
||||
```
|
||||
17
docs/api/math/quaternion/identity.md
Normal file
17
docs/api/math/quaternion/identity.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Quaternion::Identity
|
||||
|
||||
```cpp
|
||||
static Quaternion Identity()
|
||||
```
|
||||
|
||||
返回恒等四元数(无旋转)。
|
||||
|
||||
**返回:** `Quaternion` - 值为 (0, 0, 0, 1) 的四元数
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion identity = Quaternion::Identity();
|
||||
```
|
||||
17
docs/api/math/quaternion/inverse.md
Normal file
17
docs/api/math/quaternion/inverse.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Quaternion::Inverse
|
||||
|
||||
```cpp
|
||||
Quaternion Inverse() const
|
||||
```
|
||||
|
||||
返回四元数的逆(对于单位四元数就是共轭)。
|
||||
|
||||
**返回:** `Quaternion` - 逆四元数
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion inv = quat.Inverse();
|
||||
```
|
||||
21
docs/api/math/quaternion/lookrotation.md
Normal file
21
docs/api/math/quaternion/lookrotation.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Quaternion::LookRotation
|
||||
|
||||
```cpp
|
||||
static Quaternion LookRotation(const Vector3& forward, const Vector3& up = Vector3::Up())
|
||||
```
|
||||
|
||||
创建使 forward 方向朝向目标的旋转四元数。
|
||||
|
||||
**参数:**
|
||||
- `forward` - 前方向向量
|
||||
- `up` - 上方向向量(默认 Y 轴向上)
|
||||
|
||||
**返回:** `Quaternion` - 看向方向的旋转
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion lookAt = Quaternion::LookRotation(target - position);
|
||||
```
|
||||
17
docs/api/math/quaternion/magnitude.md
Normal file
17
docs/api/math/quaternion/magnitude.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Quaternion::Magnitude
|
||||
|
||||
```cpp
|
||||
float Magnitude() const
|
||||
```
|
||||
|
||||
计算四元数的模长。
|
||||
|
||||
**返回:** `float` - 四元数的模长
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
float mag = quat.Magnitude();
|
||||
```
|
||||
19
docs/api/math/quaternion/normalized.md
Normal file
19
docs/api/math/quaternion/normalized.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Quaternion::Normalized
|
||||
|
||||
```cpp
|
||||
Quaternion Normalized() const
|
||||
Quaternion Normalize(const Quaternion& q)
|
||||
```
|
||||
|
||||
归一化四元数。
|
||||
|
||||
**返回:** `Quaternion` - 归一化后的四元数
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion unit = quat.Normalized();
|
||||
Quaternion unit2 = Quaternion::Normalize(quat);
|
||||
```
|
||||
23
docs/api/math/quaternion/quaternion-multiply.md
Normal file
23
docs/api/math/quaternion/quaternion-multiply.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Quaternion * Vector3
|
||||
|
||||
```cpp
|
||||
Vector3 operator*(const Quaternion& q, const Vector3& v)
|
||||
```
|
||||
|
||||
用四元数旋转向量。
|
||||
|
||||
**参数:**
|
||||
- `q` - 旋转四元数
|
||||
- `v` - 要旋转的向量
|
||||
|
||||
**返回:** `Vector3` - 旋转后的向量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion rot = Quaternion::FromEulerAngles(0.0f, 90.0f * DEG_TO_RAD, 0.0f);
|
||||
Vector3 forward = Vector3::Forward();
|
||||
Vector3 rotated = rot * forward;
|
||||
```
|
||||
56
docs/api/math/quaternion/quaternion.md
Normal file
56
docs/api/math/quaternion/quaternion.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Quaternion
|
||||
|
||||
四元数结构体,用于表示 3D 旋转,避免欧拉角的万向锁问题。
|
||||
|
||||
**头文件:** `#include <XCEngine/Math/Quaternion.h>`
|
||||
|
||||
**命名空间:** `XCEngine::Math`
|
||||
|
||||
## 结构体定义
|
||||
|
||||
```cpp
|
||||
struct Quaternion {
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
float w = 1.0f;
|
||||
};
|
||||
```
|
||||
|
||||
## 静态工厂方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| [Identity()](identity.md) | `Quaternion` | 返回 (0, 0, 0, 1),恒等旋转 |
|
||||
| [FromAxisAngle(axis, radians)](fromaxisangle.md) | `Quaternion` | 从轴角创建 |
|
||||
| [FromEulerAngles(pitch, yaw, roll)](fromeulerangles.md) | `Quaternion` | 从欧拉角创建(弧度) |
|
||||
| [FromEulerAngles(euler)](fromeulerangles.md) | `Quaternion` | 从 Vector3 欧拉角创建 |
|
||||
| [FromRotationMatrix(matrix)](fromrotationmatrix.md) | `Quaternion` | 从旋转矩阵创建 |
|
||||
| [Slerp(a, b, t)](slerp.md) | `Quaternion` | 球面线性插值 |
|
||||
| [LookRotation(forward, up)](lookrotation.md) | `Quaternion` | 看向方向 |
|
||||
|
||||
## 实例方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| [ToEulerAngles()](toeulerangles.md) | `Vector3` | 转换为欧拉角(弧度) |
|
||||
| [ToMatrix4x4()](tomatrix4x4.md) | `Matrix4` | 转换为 4x4 旋转矩阵 |
|
||||
| [Inverse()](inverse.md) | `Quaternion` | 共轭/逆四元数 |
|
||||
| [Dot(other)](dot.md) | `float` | 点积 |
|
||||
| [Magnitude()](magnitude.md) | `float` | 模长 |
|
||||
| [Normalized()](normalized.md) | `Quaternion` | 归一化 |
|
||||
| [Normalize(q)](../vector2/normalize.md) | `Quaternion` | 归一化(静态) |
|
||||
|
||||
## 运算符
|
||||
|
||||
| 运算符 | 描述 |
|
||||
|--------|------|
|
||||
| `operator*(Quaternion, Quaternion)` | 组合旋转 |
|
||||
|
||||
## 与 Vector3 的乘法
|
||||
|
||||
[Vector3 * Quaternion](quaternion-multiply.md) - 用四元数旋转向量
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Math 模块总览](../math.md) - 返回 Math 模块总览
|
||||
22
docs/api/math/quaternion/slerp.md
Normal file
22
docs/api/math/quaternion/slerp.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Quaternion::Slerp
|
||||
|
||||
```cpp
|
||||
static Quaternion Slerp(const Quaternion& a, const Quaternion& b, float t)
|
||||
```
|
||||
|
||||
在两个四元数之间进行球面线性插值。
|
||||
|
||||
**参数:**
|
||||
- `a` - 起始四元数
|
||||
- `b` - 结束四元数
|
||||
- `t` - 插值因子(0-1)
|
||||
|
||||
**返回:** `Quaternion` - 插值结果
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion lerped = Quaternion::Slerp(rot1, rot2, 0.5f);
|
||||
```
|
||||
18
docs/api/math/quaternion/toeulerangles.md
Normal file
18
docs/api/math/quaternion/toeulerangles.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Quaternion::ToEulerAngles
|
||||
|
||||
```cpp
|
||||
Vector3 ToEulerAngles() const
|
||||
```
|
||||
|
||||
将四元数转换为欧拉角(弧度)。
|
||||
|
||||
**返回:** `Vector3` - 欧拉角 (pitch, yaw, roll)
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion rot = ...;
|
||||
Vector3 euler = rot.ToEulerAngles();
|
||||
```
|
||||
18
docs/api/math/quaternion/tomatrix4x4.md
Normal file
18
docs/api/math/quaternion/tomatrix4x4.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Quaternion::ToMatrix4x4
|
||||
|
||||
```cpp
|
||||
Matrix4x4 ToMatrix4x4() const
|
||||
```
|
||||
|
||||
将四元数转换为 4x4 旋转矩阵。
|
||||
|
||||
**返回:** `Matrix4x4` - 旋转矩阵
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Quaternion rot = ...;
|
||||
Matrix4 mat = rot.ToMatrix4x4();
|
||||
```
|
||||
Reference in New Issue
Block a user