docs: update math API docs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Math::DEG_TO_RAD
|
||||
|
||||
```cpp
|
||||
constexpr float DEG_TO_RAD = Math::PI / 180.0f;
|
||||
constexpr float DEG_TO_RAD = PI / 180.0f;
|
||||
```
|
||||
|
||||
`DEG_TO_RAD` 是角度转弧度的转换系数。1 度等于 `PI / 180` 弧度,约等于 0.01745329251994329577。使用该常量将角度值乘以 `DEG_TO_RAD` 即可得到对应的弧度值。
|
||||
|
||||
@@ -13,7 +13,7 @@ constexpr float EPSILON = 1e-6f;
|
||||
|
||||
float a = 0.1f + 0.2f;
|
||||
float b = 0.3f;
|
||||
if (Math::Abs(a - b) < Math::EPSILON) {
|
||||
if (fabsf(a - b) < Math::EPSILON) {
|
||||
// a 和 b 可以视为相等
|
||||
}
|
||||
```
|
||||
|
||||
@@ -11,7 +11,7 @@ constexpr float FLOAT_MAX = 3.402823466e+38f;
|
||||
```cpp
|
||||
#include <XCEngine/Math/Math.h>
|
||||
|
||||
float maxDistance = Math::FLOAT_MAX;
|
||||
float maxDistance = FLOAT_MAX;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
**类型**: `header`
|
||||
|
||||
**头文件**: `XCEngine/Math/Math.h`
|
||||
|
||||
**描述**: 数学库常量和辅助函数头文件。
|
||||
|
||||
## 概述
|
||||
@@ -41,7 +43,7 @@ float angle = 90.0f * DEG_TO_RAD; // 90度转弧度
|
||||
|
||||
// 使用函数
|
||||
float rad = Radians(180.0f); // 180度 -> π 弧度
|
||||
float deg = Degrees(Math::PI); // π 弧度 -> 180度
|
||||
float deg = Degrees(PI); // π 弧度 -> 180度
|
||||
|
||||
// 比较浮点数
|
||||
if (fabsf(a - b) < EPSILON) {
|
||||
|
||||
@@ -11,7 +11,7 @@ constexpr float HALF_PI = 1.57079632679489661923f;
|
||||
```cpp
|
||||
#include <XCEngine/Math/Math.h>
|
||||
|
||||
float ninetyDegreesRadians = Math::HALF_PI;
|
||||
float ninetyDegreesRadians = HALF_PI;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
@@ -13,8 +13,8 @@ constexpr float PI = 3.14159265358979323846f;
|
||||
```cpp
|
||||
#include <XCEngine/Math/Math.h>
|
||||
|
||||
float circumference = 2.0f * Math::PI * radius;
|
||||
float area = Math::PI * radius * radius;
|
||||
float circumference = 2.0f * PI * radius;
|
||||
float area = PI * radius * radius;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Math::RAD_TO_DEG
|
||||
|
||||
```cpp
|
||||
constexpr float RAD_TO_DEG = 180.0f / Math::PI;
|
||||
constexpr float RAD_TO_DEG = 180.0f / PI;
|
||||
```
|
||||
|
||||
`RAD_TO_DEG` 是弧度转角度的转换系数。1 弧度等于 `180 / PI` 度,约等于 57.29577951308232087685。使用该常量将弧度值乘以 `RAD_TO_DEG` 即可得到对应的角度值。
|
||||
|
||||
@@ -11,7 +11,7 @@ constexpr float TWO_PI = 6.28318530717958647692f;
|
||||
```cpp
|
||||
#include <XCEngine/Math/Math.h>
|
||||
|
||||
float fullCircleRadians = Math::TWO_PI;
|
||||
float fullCircleRadians = TWO_PI;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
Reference in New Issue
Block a user