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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
# Math
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::Math`
|
|
|
|
|
|
|
|
|
|
**类型**: `header`
|
|
|
|
|
|
2026-03-26 02:41:00 +08:00
|
|
|
**头文件**: `XCEngine/Core/Math/Math.h`
|
2026-03-20 02:35:15 +08:00
|
|
|
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
**描述**: 数学库常量和辅助函数头文件。
|
|
|
|
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
`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
|
2026-03-26 02:41:00 +08:00
|
|
|
#include <XCEngine/Core/Math/Math.h>
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
|
|
|
using namespace XCEngine::Math;
|
|
|
|
|
|
|
|
|
|
// 使用常量
|
|
|
|
|
float angle = 90.0f * DEG_TO_RAD; // 90度转弧度
|
|
|
|
|
|
|
|
|
|
// 使用函数
|
|
|
|
|
float rad = Radians(180.0f); // 180度 -> π 弧度
|
2026-03-20 02:35:15 +08:00
|
|
|
float deg = Degrees(PI); // π 弧度 -> 180度
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
|
|
|
// 比较浮点数
|
|
|
|
|
if (fabsf(a - b) < EPSILON) {
|
|
|
|
|
// 认为 a 和 b 相等
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
|
|
|
- [Math 模块总览](../math.md) - 返回 Math 模块总览
|