Files
XCEngine/docs/api/math/h/h.md
ssdfasd b414bc5326 refactor(docs): Fix broken links across multiple modules
Fixed broken references:
- texture-import-settings: Fix 16 files referencing wrong overview filename
- math/rectint: Fix 9 method links (rectint-* → get*, contains, intersects)
- rhi/opengl/device: Fix 8 cross-references (opengl-* → */**)
- resources/mesh: Fix meshsection and vertexattribute links
- rhi/d3d12/sampler: Fix RHISampler reference path
- math/vector3: Fix projectonplane → project-on-plane
- rhi/opengl/command-list: Remove broken ClearFlag enum ref
- rhi/opengl/device: Create 2 new method docs (MakeContextCurrent, GetNativeContext)
- rhi/device: Fix device-info types reference

All 0 broken references remaining.
2026-03-26 02:41:00 +08:00

1.4 KiB

Math

命名空间: XCEngine::Math

类型: header

头文件: XCEngine/Core/Math/Math.h

描述: 数学库常量和辅助函数头文件。

概述

Math.h 提供了图形引擎常用的数学常量和辅助函数,包括圆周率、角度转换、浮点精度等基础常量,以及角度弧度转换等常用函数。

常量

常量 描述
PI 3.14159265358979323846f 圆周率
TWO_PI 6.28318530717958647692f
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 浮点最大值

辅助函数

函数 描述
Radians 度转弧度
Degrees 弧度转度

使用示例

#include <XCEngine/Core/Math/Math.h>

using namespace XCEngine::Math;

// 使用常量
float angle = 90.0f * DEG_TO_RAD;  // 90度转弧度

// 使用函数
float rad = Radians(180.0f);        // 180度 -> π 弧度
float deg = Degrees(PI);      // π 弧度 -> 180度

// 比较浮点数
if (fabsf(a - b) < EPSILON) {
    // 认为 a 和 b 相等
}

相关文档