code: def quaternion_slerp(a, b, t):
      
      if a is None:
          a = unit_quaternion()
      if b is None:
          b = unit_quaternion()
      # calc cosine
      cosom = np.dot(a, b)
      # adjust signs (if necessary)
      if cosom < 0.0:
          cosom = -cosom
          b = -b
  
      # calculate coefficients
      if (1.0 - cosom) > 0.000001:
          # standard case (slerp)
          omega = math.acos(cosom)
          sinom = math.sin(omega)
          scale0 = math.sin((1.0 - t) * omega) / sinom
          scale1 = math.sin(t * omega) / sinom
      else:
          # "from" and "to" quaternions are very close
          #  ... so we can do a linear interpolation
          scale0 = 1.0 - t
          scale1 = t
      return scale0 * a + scale1 * b
docs: Spherical linear interpolation for unit quaternions.
  
      This is based on the implementation in the gl-matrix package:
      https://github.com/toji/gl-matrix