refactor: reorganize docs into plan/ and add skills/
This commit is contained in:
47
docs/api/math/math-sphere.md
Normal file
47
docs/api/math/math-sphere.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Sphere
|
||||
|
||||
3D 球体结构体。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Sphere.h>
|
||||
```
|
||||
|
||||
## 命名空间
|
||||
|
||||
`XCEngine::Math`
|
||||
|
||||
## 结构体定义
|
||||
|
||||
```cpp
|
||||
struct Sphere {
|
||||
Vector3 center = Vector3::Zero();
|
||||
float radius = 0.0f;
|
||||
};
|
||||
```
|
||||
|
||||
## 构造函数
|
||||
|
||||
- `Sphere()` - 默认构造
|
||||
- `Sphere(const Vector3& center, float radius)` - 从中心和半径构造
|
||||
|
||||
## 实例方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| `Contains(point)` | `bool` | 点是否在球体内(包括表面) |
|
||||
| `Intersects(other)` | `bool` | 与另一个球体是否相交 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
Sphere sphere(Vector3(0.0f, 0.0f, 0.0f), 1.0f);
|
||||
|
||||
// 检测点
|
||||
if (sphere.Contains(Vector3(0.5f, 0.0f, 0.0f))) { ... }
|
||||
|
||||
// 检测球体相交
|
||||
Sphere other(Vector3(1.0f, 0.0f, 0.0f), 1.0f);
|
||||
if (sphere.Intersects(other)) { ... }
|
||||
```
|
||||
Reference in New Issue
Block a user