fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
This commit is contained in:
100
docs/api/math/math.md
Normal file
100
docs/api/math/math.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# Math 模块概览
|
||||
|
||||
**命名空间**: `XCEngine::Math`
|
||||
|
||||
**类型**: `module`
|
||||
|
||||
**描述**: XCEngine 的数学库模块,提供图形引擎常用的数学类型和函数。
|
||||
|
||||
## 概述
|
||||
|
||||
Math 模块提供了一套完整的图形数学库,包括向量、矩阵、四元数、变换和几何类型等。
|
||||
|
||||
## 模块内容
|
||||
|
||||
### 向量类型
|
||||
|
||||
| 组件 | 文件 | 描述 |
|
||||
|------|------|------|
|
||||
| [Vector2](vector2/vector2.md) | `Vector2.h` | 二维向量 |
|
||||
| [Vector3](vector3/vector3.md) | `Vector3.h` | 三维向量 |
|
||||
| [Vector4](vector4/vector4.md) | `Vector4.h` | 四维向量 |
|
||||
|
||||
### 矩阵类型
|
||||
|
||||
| 组件 | 文件 | 描述 |
|
||||
|------|------|------|
|
||||
| [Matrix3](matrix3/matrix3.md) | `Matrix3.h` | 3x3 矩阵 |
|
||||
| [Matrix4](matrix4/matrix4.md) | `Matrix4.h` | 4x4 矩阵 |
|
||||
|
||||
### 旋转/变换
|
||||
|
||||
| 组件 | 文件 | 描述 |
|
||||
|------|------|------|
|
||||
| [Quaternion](quaternion/quaternion.md) | `Quaternion.h` | 四元数 |
|
||||
| [Transform](transform/transform.md) | `Transform.h` | 变换组件 |
|
||||
|
||||
### 几何类型
|
||||
|
||||
| 组件 | 文件 | 描述 |
|
||||
|------|------|------|
|
||||
| [Color](color/color.md) | `Color.h` | 颜色 |
|
||||
| [Ray](ray/ray.md) | `Ray.h` | 射线 |
|
||||
| [Plane](plane/plane.md) | `Plane.h` | 平面 |
|
||||
| [Sphere](sphere/sphere.md) | `Sphere.h` | 球体 |
|
||||
| [Box](box/box.md) | `Box.h` | 盒子 |
|
||||
| [Bounds](bounds/bounds.md) | `Bounds.h` | 包围盒 |
|
||||
| [AABB](aabb/aabb.md) | `AABB.h` | 轴对齐包围盒 |
|
||||
| [Frustum](frustum/frustum.md) | `Frustum.h` | 视锥体 |
|
||||
| [Rect](rect/rect.md) | `Rect.h` | 二维矩形 |
|
||||
|
||||
## 常量定义
|
||||
|
||||
| 常量 | 值 | 描述 |
|
||||
|------|-----|------|
|
||||
| `PI` | 3.14159265358979323846f | 圆周率 |
|
||||
| `TWO_PI` | 6.28318530717958647692f | 2π |
|
||||
| `HALF_PI` | 1.57079632679489661923f | π/2 |
|
||||
| `DEG_TO_RAD` | PI / 180.0f | 度到弧度 |
|
||||
| `RAD_TO_DEG` | 180.0f / PI | 弧度到度 |
|
||||
| `EPSILON` | 1e-6f | 浮点精度 |
|
||||
| `FLOAT_MAX` | 3.402823466e+38f | 浮点最大值 |
|
||||
|
||||
详细文档: [Math.h - 常量和辅助函数](h/h.md)
|
||||
|
||||
## 辅助函数
|
||||
|
||||
| 函数 | 描述 |
|
||||
|------|------|
|
||||
| `Radians(float degrees)` | 度转弧度 |
|
||||
| `Degrees(float radians)` | 弧度转度 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Math.h>
|
||||
#include <XCEngine/Math/Vector3.h>
|
||||
#include <XCEngine/Math/Matrix4.h>
|
||||
#include <XCEngine/Math/Quaternion.h>
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
|
||||
// 向量运算
|
||||
Vector3 a(1.0f, 0.0f, 0.0f);
|
||||
Vector3 b(0.0f, 1.0f, 0.0f);
|
||||
float dot = Vector3::Dot(a, b);
|
||||
Vector3 cross = Vector3::Cross(a, b);
|
||||
Vector3 normalized = Vector3::Normalize(a);
|
||||
|
||||
// 矩阵运算
|
||||
Matrix4 model = Matrix4::TRS(position, rotation, scale);
|
||||
Matrix4 view = Matrix4::LookAt(eye, target, up);
|
||||
Matrix4 projection = Matrix4::Perspective(fov, aspect, near, far);
|
||||
Matrix4 mvp = projection * view * model;
|
||||
|
||||
// 四元数运算
|
||||
Quaternion q1 = Quaternion::FromEulerAngles(0, 90 * DEG_TO_RAD, 0);
|
||||
Quaternion q2 = Quaternion::FromAxisAngle(Vector3::Up(), Math::Radians(45.0f));
|
||||
Quaternion combined = q1 * q2;
|
||||
Vector3 rotated = q2 * Vector3::Forward();
|
||||
```
|
||||
Reference in New Issue
Block a user