D3DXQUATERNION * WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pOut,
   CONST D3DXQUATERNION *pQ1,
   CONST D3DXQUATERNION *pQ2,
   FLOAT t)
{
   float s = 1.0f - t;
   float dot = D3DXQuaternionDot(pQ1, pQ2);
   if (dot < 0.0f) { t = -t; dot = -dot; } if (1.0f - dot > 0.00001f)
   {
      float theta = acosf(dot);
      s = sinf(theta * s) / sinf(theta);
      t = sinf(theta * t) / sinf(theta);
   }
   *pOut = s * *pQ1 + t * *pQ2;
   return pOut;
}

Leave a Reply

Your email address will not be published. Required fields are marked *