Files
XCEngine/docs/api/math/rect/contains.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.1 KiB
Raw Blame History

Rect::Contains

判断点是否在矩形内部。

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)

示例:

#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;
}

相关文档