after some experimentation to optimize slerp I found that finding the middle between quaternion is rather cheap (for $t=0.5$)

in particular: (with $\theta$ the angle between $q_1$ and $q_1$)

$$slerp(q_1, q_2, 0.5) = \frac{q_1 \sin\frac\theta2 + q_2 \sin\frac\theta2}{\sin\theta}$$

$$=(q_1+q_2) \frac{\sin\frac\theta2}{\sin\theta}$$

with the double angle formula you get

$$=(q_1+q_2) \frac{\sin\frac\theta2}{2\sin\frac\theta2 \cos\frac\theta2}=\frac{q_1+q_2}{2\cos\frac\theta2}=norm(q_1+q_2)$$

then to use this you can do:

$$rslerp(q_1, q_2, t)=\left\{ \begin{array}{1,1} norm((1-t)q_1+t\cdot q_2) & \text{if $dot(q_1, q_2)>0.9995$}\\ rslerp(q_1, norm(q_1+q_2), 2t) & \text{if $t<0.5$}\\ rslerp(norm(q_1+q_2),q_2, 2t-1) & \text{if $t>0.5$} \end{array} \right.$$

in effect you never need to get the angle between the 2 quaternions so you can skip the expensive acos and only need a square root per recursion step

now for my actual question:

  • First, is this last step even correct?
  • How numerically stable is this?

    Only problem I can see is the normalization (aka division by $2\cos\frac\theta2$) which may be bad when $q_1$ and $q_2$ are nearly $\pi$ apart; but that is present in the classic slerp anyway (with the division by $\sin\theta$)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.