984 B
984 B
Plane::GetDistanceToPoint
float GetDistanceToPoint(const Vector3& point) const
计算点到平面的有符号距离。正值表示点在法线方向一侧,负值表示点在法线相反方向一侧,零值表示点在平面上。
参数:
point- 要计算的点
返回: float - 点到平面的有符号距离
线程安全: ✅
复杂度: O(1)
示例:
#include <XCEngine/Math/Plane.h>
#include <XCEngine/Math/Vector3.h>
#include <cstdio>
using namespace XCEngine::Math;
void GetDistanceToPointExample() {
Plane plane(Vector3::Up(), 0.0f);
Vector3 point1(0.0f, 2.0f, 0.0f);
float dist1 = plane.GetDistanceToPoint(point1);
Vector3 point2(0.0f, -3.0f, 0.0f);
float dist2 = plane.GetDistanceToPoint(point2);
}
相关文档
- Plane 类总览 - 返回类总览
- GetClosestPoint - 计算平面上最接近点
- GetSide - 判断点在哪一侧