935 B
935 B
Plane::Intersects
bool Intersects(const Sphere& sphere) const
检测平面是否与球体相交。球体与平面相交的条件是:球心到平面的有符号距离的绝对值小于等于球体半径。
参数:
sphere- 要检测的球体
返回: bool - true 表示相交,false 表示不相交
线程安全: ✅
复杂度: O(1)
示例:
#include <XCEngine/Math/Plane.h>
#include <XCEngine/Math/Sphere.h>
#include <XCEngine/Math/Vector3.h>
using namespace XCEngine::Math;
void IntersectsExample() {
Plane plane(Vector3::Up(), 0.0f);
Sphere sphere1(Vector3(0.0f, 0.5f, 0.0f), 1.0f);
bool intersects1 = plane.Intersects(sphere1);
Sphere sphere2(Vector3(0.0f, 5.0f, 0.0f), 1.0f);
bool intersects2 = plane.Intersects(sphere2);
}