slerp

giant.rotations:

giant.rotations.slerp(quaternion0, quaternion1, time, time0=0, time1=1)[source]

This function performs spherical linear interpolation of rotation quaternions.

SLERP of quaternions involves performing a linear interpolation along the great circle arc connecting the two quaternions. That is:

\[\begin{split}\omega = \text{cos}^{-1}(\mathbf{q}_0^T\mathbf{q}_1)\\ \mathbf{q}=\mathbf{q}_0\text{cos}(p\omega)+ \text{sin}(p\omega)\frac{\mathbf{q}_1-\mathbf{q}_0\text{cos}(\omega)} {\left\|\mathbf{q}_1-\mathbf{q}_0\text{cos}(\omega)\right\|}\\ \mathbf{q} = \frac{\mathbf{q}}{\left\|\mathbf{q}\right\|}\end{split}\]

where \(\mathbf{q}\) is the interpolated quaternion, \(\mathbf{q}_0\) is the starting quaternion, \(\mathbf{q}_1\) is the ending quaternion, \(\omega\) is the angle between the first and second quaternion, and \(p\) is the fractional percent of the way between \(\mathbf{q}_0\) and \(\mathbf{q}_1\) that we want to interpolate at (\(p\in[0, 1]\))

When using this function you can either specify the argument time as the fractional percent that you want to interpolate at, or specify the keyword arguments time0 and time1 to be the times corresponding to the first and second quaternion respectively and the function will compute the fractional percent for you. When using this method it is also possible to specify all three of time, time0, and time1 as python datetime objects.

Parameters:
  • quaternion0 (Sequence | ndarray | Rotation) – The starting quaternion(s)

  • quaternion1 (Sequence | ndarray | Rotation) – The ending quaternion(s)

  • time (Real | datetime) – The time to interpolate the quaternions at, as a fractional percent or as the actual time between time0 and time1

  • time0 (Real | datetime) – the time(s) corresponding to the first quaternion(s). Leave at 0 if you are specifying time as a fractional percent

  • time1 (Real | datetime) – the time(s) corresponding to the second quaternion(s). Leave at 1 if you are specifying time as a fractional percent

Returns:

The interpolated quaternion(s)

Return type:

ndarray | Rotation