public static XMVector Ln(XMVector q) { XMVector oneMinusEpsilon = XMVector.FromFloat(1.0f - 0.00001f, 1.0f - 0.00001f, 1.0f - 0.00001f, 1.0f - 0.00001f); XMVector qw = XMVector.SplatW(q); XMVector q0 = XMVector.Select(XMGlobalConstants.Select1110, q, XMGlobalConstants.Select1110); XMVector controlW = qw.InBounds(oneMinusEpsilon); XMVector theta = qw.ACos(); XMVector sinTheta = theta.Sin(); XMVector s = XMVector.Divide(theta, sinTheta); XMVector result = XMVector.Multiply(q0, s); result = XMVector.Select(q0, result, controlW); return(result); }