VectorPlaneProject
/** * Calculate the projection of a vector on the plane defined by PlaneNormal. * * @param V The vector to project onto the plane. * @param PlaneNormal Normal of the plane (assumed to be unit length). * @return Projection of V onto plane. */ FVector FVector::VectorPlaneProject(const FVector& V, const FVector& PlaneNormal) { return V - V.ProjectOnToNormal(PlaneNormal); }
设O为PlaneNormal上的一点(可以为原点),ON为PlaneNormal,将OV投影到ON为OQ,投影点Q为PlaneNormal上离V最近的点。此时QV即为所求:OV到Plane上的投影。
OQ + QV = OV => QV = OV - OQ
OQ = (V.Dot(Normal)) * Normal
因此,最后所求QV = OV - OQ = V - (V.Dot(Normal))* Normal.
其中,(V.Dot(Normal)) * Normal记为函数V.ProjectOnToNormal(Normal).
ColorCorrectRegionsCommon.usf中的RotateAboutAxis函数,其实现里的ClosestPointOnAxis就是Q点,UAxis就是QV