Пример #1
0
        public static XMVector FromPoints(XMVector point1, XMVector point2, XMVector point3)
        {
            XMVector v21 = XMVector.Subtract(point1, point2);
            XMVector v31 = XMVector.Subtract(point1, point3);

            XMVector n = XMVector3.Cross(v21, v31);

            n = XMVector3.Normalize(n);

            XMVector d = XMPlane
                         .DotNormal(n, point1)
                         .Negate();

            return(XMVector.Select(d, n, XMGlobalConstants.Select1110));
        }
Пример #2
0
        public static void IntersectPlane(out XMVector linePoint1, out XMVector linePoint2, XMVector p1, XMVector p2)
        {
            XMVector v1       = XMVector3.Cross(p2, p1);
            XMVector lengthSq = XMVector3.LengthSquare(v1);
            XMVector v2       = XMVector3.Cross(p2, v1);
            XMVector p1W      = XMVector.SplatW(p1);
            XMVector point    = XMVector.Multiply(v2, p1W);
            XMVector v3       = XMVector3.Cross(v1, p1);
            XMVector p2W      = XMVector.SplatW(p2);

            point = XMVector.MultiplyAdd(v3, p2W, point);

            XMVector lineP1 = XMVector.Divide(point, lengthSq);
            XMVector lineP2 = XMVector.Add(lineP1, v1);

            XMVector control = XMVector.LessOrEqual(lengthSq, XMGlobalConstants.Epsilon);

            linePoint1 = XMVector.Select(lineP1, XMGlobalConstants.QNaN, control);
            linePoint2 = XMVector.Select(lineP2, XMGlobalConstants.QNaN, control);
        }