gaitmap.utils.rotations.find_rotation_around_axis#

gaitmap.utils.rotations.find_rotation_around_axis(rot: Rotation, rotation_axis: ndarray | list) Rotation[source]#

Calculate the rotation component of rot around the given rotation axis.

This performs a swing-twist decomposition of the rotation quaternion [1]. The returned rotation is the twist component of this decomposition. This is equivalent to the rotation around the rotation axis.

Parameters:
rotsingle or multi rotation

The rotation

rotation_axis(3,) or (n,3) vector

The axis around which the rotation component should be extracted. In case a single rotation axis and multiple rotations are provided, the angle is extracted around the same axis for all rotations. In case n axis are provided for n rotations, the angle for each rotation is extracted around the respective axis.

Notes

Examples

>>> # Create composite rotation around y and z axis
>>> rot = Rotation.from_rotvec([0, 0, np.pi / 2]) * Rotation.from_rotvec([0, np.pi / 4, 0])
>>> find_rotation_around_axis(rot, [0, 0, 1]).as_rotvec()  # Extract part around z
array([0.        , 0.        , 1.57079633])
>>> find_rotation_around_axis(rot, [0, 1, 0]).as_rotvec()  # Extract part around y
array([0.        , 0.78539816, 0.        ])