/// <summary> /// 空间中一个点在一个面上的投影点 /// </summary> /// <param name="face"></param> /// <param name="point"></param> /// <returns></returns> public static Vector3 ProjectPointOnPlane(Face face, Vector3 point) { float num = Math3d.SignedDistancePlanePoint(face, point); num *= -1f; Vector3 b = Math3d.SetVectorLength(face.normal, num); return(point + b); }
/// <summary> /// 线面是否相交 /// </summary> /// <param name="intersection">交点</param> /// <param name="linePoint"></param> /// <param name="lineVec"></param> /// <param name="face"></param> /// <returns>是否相交</returns> public static bool LinePlaneIntersection(Vector3 linePoint, Vector3 lineVec, Face face, out Vector3 intersection) { intersection = Vector3.zero; float num = Vector3.Dot(face.point - linePoint, face.normal); float num2 = Vector3.Dot(lineVec, face.normal); if (num2 != 0f) { float size = num / num2; Vector3 b = Math3d.SetVectorLength(lineVec, size); intersection = linePoint + b; return(true); } return(false); }