fractaldna.utils.rotations.quaternion_slerp¶
- fractaldna.utils.rotations.quaternion_slerp(quat0, quat1, fraction, spin=0, shortestpath=True)¶
Return spherical linear interpolation between two quaternions. shortestpath = True: force shortest path shortestpath = False: force longest path shortestpath = None: no path forcing
>>> q0 = random_quaternion() >>> q1 = random_quaternion() >>> q = quaternion_slerp(q0, q1, 0) >>> np.allclose(q, q0) True >>> q = quaternion_slerp(q0, q1, 1, 1) >>> np.allclose(q, q1) True >>> q = quaternion_slerp(q0, q1, 0.5) >>> angle = math.acos(np.dot(q0, q)) >>> np.allclose(2, math.acos(np.dot(q0, q1)) / angle) or np.allclose(2, math.acos(-np.dot(q0, q1)) / angle) True