Пример #1
0
        public static XMVector BaryCentricV(XMVector q0, XMVector q1, XMVector q2, XMVector f, XMVector g)
        {
            Debug.Assert(f.Y == f.X && f.Z == f.X && f.W == f.X, "Reviewed");
            Debug.Assert(g.Y == g.X && g.Z == g.X && g.W == g.X, "Reviewed");

            XMVector epsilon = XMVector.FromSplatConstant(1, 16);
            XMVector s       = XMVector.Add(f, g);

            XMVector result;

            if (XMVector4.InBounds(s, epsilon))
            {
                result = q0;
            }
            else
            {
                XMVector q01 = XMQuaternion.SlerpV(q0, q1, s);
                XMVector q02 = XMQuaternion.SlerpV(q0, q2, s);
                XMVector gs  = s.Reciprocal();
                gs = XMVector.Multiply(g, gs);

                result = XMQuaternion.SlerpV(q01, q02, gs);
            }

            return(result);
        }