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.
50 lines
1.1 KiB
Markdown
50 lines
1.1 KiB
Markdown
# Rect::Contains
|
||
|
||
判断点是否在矩形内部。
|
||
|
||
```cpp
|
||
bool Contains(float px, float py) const;
|
||
bool Contains(const Vector2& point) const;
|
||
```
|
||
|
||
矩形使用左上位坐标系,内部定义为:x >= left && x < right && y >= top && y < bottom。即左边界和上边界在内部,右边界和下边界在外部。
|
||
|
||
**参数:**
|
||
- `px` - 点的 x 坐标
|
||
- `py` - 点的 y 坐标
|
||
- `point` - 要判断的点(Vector2 类型)
|
||
|
||
**返回:** 点在矩形内部返回 true,否则返回 false
|
||
|
||
**线程安全:** ✅
|
||
|
||
**复杂度:** O(1)
|
||
|
||
**示例:**
|
||
|
||
```cpp
|
||
#include "XCEngine/Core/Math/Rect.h"
|
||
#include <iostream>
|
||
|
||
using namespace XCEngine::Math;
|
||
|
||
int main() {
|
||
Rect rect(10.0f, 20.0f, 100.0f, 50.0f);
|
||
|
||
if (rect.Contains(50.0f, 30.0f)) {
|
||
std::cout << "Point (50, 30) is inside\n";
|
||
}
|
||
|
||
Vector2 point(150.0f, 100.0f);
|
||
if (!rect.Contains(point)) {
|
||
std::cout << "Point (150, 100) is outside\n";
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [`Rect::Intersects`](intersects.md) - 判断是否相交
|
||
- [Rect 总览](rect.md) |