gaitmap.utils.rotations.find_shortest_rotation#

gaitmap.utils.rotations.find_shortest_rotation(v1: ndarray, v2: ndarray) Rotation[source]#

Find a quaternion that rotates v1 into v2 via the shortest way.

Parameters:
v1vector with shape (3,)

axis ([x, y ,z])

v2vector with shape (3,)

axis ([x, y ,z])

Returns:
rotation

Shortest rotation that rotates v1 into v2

Examples

>>> goal = np.array([0, 0, 1])
>>> start = np.array([1, 0, 0])
>>> rot = find_shortest_rotation(start, goal)
>>> rotated = rot.apply(start)
>>> rotated
array([0., 0., 1.])