public static XMVector InverseRotate(XMVector v, XMVector rotationQuaternion) { //// Transform a vector using the inverse of a rotation expressed as a unit quaternion XMVector a = XMVector.Select(XMGlobalConstants.Select1110, v, XMGlobalConstants.Select1110); XMVector result = XMQuaternion.Multiply(rotationQuaternion, a); XMVector q = XMQuaternion.Conjugate(rotationQuaternion); return(XMQuaternion.Multiply(result, q)); }
public static XMVector Inverse(XMVector q) { XMVector zero = XMVector.Zero; XMVector l = XMVector4.LengthSquare(q); XMVector conjugate = XMQuaternion.Conjugate(q); XMVector control = XMVector.LessOrEqual(l, XMGlobalConstants.Epsilon); XMVector result = XMVector.Divide(conjugate, l); result = XMVector.Select(result, zero, control); return(result); }