Files
XCEngine/docs/api/math/ray/ray-constructor.md

34 lines
574 B
Markdown
Raw Normal View History

2026-03-20 02:35:15 +08:00
# Ray::Ray (构造函数)
```cpp
Ray(const Vector3& origin, const Vector3& direction)
```
从起点和方向构造射线。
**参数:**
- `origin` - 射线起点
- `direction` - 射线方向(构造时会被归一化)
**返回:** 无
**线程安全:** ✅
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Math/Ray.h>
#include <XCEngine/Math/Vector3.h>
using namespace XCEngine::Math;
Ray ray(Vector3(0.0f, 0.0f, 0.0f), Vector3(1.0f, 0.0f, 0.0f));
// direction 已被归一化
```
## 相关文档
- [Ray 类总览](ray.md) - 返回类总览