gaitmap.utils.rotations.find_angle_between_orientations#

gaitmap.utils.rotations.find_angle_between_orientations(ori: Rotation, ref: Rotation, rotation_axis: ndarray | None = None) float | ndarray[source]#

Get the required rotation angle between two orientations.

This will return the angle around the rotation axis that transforms ori into ref in this dimension.

Parameters:
oriSingle or rotation object with n rotations

The initial orientation

refSingle or rotation object with n rotations

The reference orientation

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

The axis of rotation around which the angle is calculated. If None the shortest possible rotation angle between the two quaternions is returned.

Returns:
angle

The angle around the given axis in rad between -np.pi and np.pi. The sign is defined by the right-hand-rule around the provided axis ond the order or ori and ref. If no axis is provided, the angle will always be positive.

Notes

This function works for multiple possible combinations of input-dimensions:

  • ori: 1, ref: 1, rotation_axis: (3,) / (1,3) -> angle: float

  • ori: n, ref: 1, rotation_axis: (3,) / (1,3) / (n,3) -> angle: (n,)

  • ori: 1, ref: n, rotation_axis: (3,) / (1,3) / (n,3) -> angle: (n,)

  • ori: n, ref: n, rotation_axis: (3,) / (1,3) / (n,3) -> angle: (n,)