nlerp

giant.rotations:

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

This function performs normalized linear interpolation of rotation quaternions.

NLERP of quaternions involves first performing a linear interpolation between the two vectors, and then normalizing the interpolated result to have unit length. That is:

\[\mathbf{q}=\frac{\mathbf{q}_0(1-p)+\mathbf{q}_1p} {\left\|\mathbf{q}_0(1-p)+\mathbf{q}_1p\right\|}\]

where \(\mathbf{q}\) is the interpolated quaternion, \(\mathbf{q}_0\) is the starting quaternion, \(\mathbf{q}_1\) is the ending 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.

Warning

NLERP is a very fast and efficient interpolation method that is fine for short interpolation intervals; however, it does not perform a constant angular velocity interpolation (and instead performs a constant linear velocity interpolation), therefore it is not well suited to interpolating over long time intervals. If you need to interpolate over larger time intervals it is better to use the slerp() function which does perform constant angular velocity interpolation (but is less efficient).

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