skrobot.coordinates.math.quaternion_slerp

skrobot.coordinates.math.quaternion_slerp(q0, q1, fraction, spin=0, shortestpath=True)[source]

Return spherical linear interpolation between two quaternions.

Parameters:
Returns:

quaternion – spherical linear interpolated quaternion

Return type:

numpy.ndarray

Examples

>>> q0 = random_quaternion()
>>> q1 = random_quaternion()
>>> q = quaternion_slerp(q0, q1, 0.0)
>>> numpy.allclose(q, q0)
True
>>> q = quaternion_slerp(q0, q1, 1.0, 1)
>>> numpy.allclose(q, q1)
True
>>> q = quaternion_slerp(q0, q1, 0.5)
>>> angle = math.acos(numpy.dot(q0, q))
>>> numpy.allclose(2.0, math.acos(numpy.dot(q0, q1)) / angle) or         numpy.allclose(2.0, math.acos(-numpy.dot(q0, q1)) / angle)
True