Spherical linear interpolation

`q0 = slerp(q1,q2,T)`

Quaternion **s**pherical **l**inear int**erp**olation (SLERP) is an extension of linear interpolation
along a plane to spherical interpolation in three dimensions. The algorithm was first
proposed in [1]. Given two
quaternions, *q*_{1} and
*q*_{2}, SLERP interpolates a new quaternion,
*q*_{0}, along the great circle that connects
*q*_{1} and
*q*_{2}. The interpolation coefficient,
*T*, determines how close the output quaternion is to either
*q*_{1} and
*q*_{2}.

The SLERP algorithm can be described in terms of sinusoids:

$${q}_{0}=\frac{\mathrm{sin}\left((1-T)\theta \right)}{\mathrm{sin}\left(\theta \right)}{q}_{1}+\frac{\mathrm{sin}\left(T\theta \right)}{\mathrm{sin}\left(\theta \right)}{q}_{2}$$

where *q*_{1} and
*q*_{2} are normalized quaternions, and
*θ* is half the angular distance between
*q*_{1} and
*q*_{2}.

[1] Shoemake, Ken. "Animating Rotation with
Quaternion Curves." *ACM SIGGRAPH Computer Graphics* Vol. 19, Issue
3, 1985, pp. 345–354.