PointPlaneProject
/** * Calculate the projection of a point on the given plane. * * @param Point The point to project onto the plane * @param Plane The plane * @return Projection of Point onto Plane */ FVector FVector::PointPlaneProject(const FVector& Point, const FPlane& Plane) { //Find the distance of X from the plane //Add the distance back along the normal from the point return Point - Plane.PlaneDot(Point) * Plane; }
设投影点是Q,有OP = OQ + QP. 因此Q点坐标即OQ = OP - QP
QP = (Point到Plane的有向距离) * (Plane.Normal). 当P在正空间时,有向距离为正,QP结果与Normal同向;当P在负空间时,有向距离为负,QP结果与Normal反向。因此这里的QP计算式是正确的,符合事实。