gaitmap.utils.rotations.rotation_from_angle#

gaitmap.utils.rotations.rotation_from_angle(axis: ndarray, angle: float | ndarray) Rotation[source]#

Create a rotation based on a rotation axis and a angle.

Parameters:
axisarray with shape (3,) or (n, 3)

normalized rotation axis ([x, y ,z]) or array of rotation axis

anglefloat or array with shape (n,)

rotation angle or array of angeles in rad

Returns:
rotation(s)Rotation object with len n

Examples

Single rotation: 180 deg rotation around the x-axis

>>> rot = rotation_from_angle(np.array([1, 0, 0]), np.deg2rad(180))
>>> rot.as_quat().round(decimals=3)
array([1., 0., 0., 0.])
>>> rot.apply(np.array([[0, 0, 1.0], [0, 1, 0.0]])).round()
array([[ 0., -0., -1.],
       [ 0., -1.,  0.]])

Multiple rotations: 90 and 180 deg rotation around the x-axis

>>> rot = rotation_from_angle(np.array([1, 0, 0]), np.deg2rad([90, 180]))
>>> rot.as_quat().round(decimals=3)
array([[0.707, 0.   , 0.   , 0.707],
       [1.   , 0.   , 0.   , 0.   ]])
>>> # In case of multiple rotations, the first rotation is applied to the first vector
>>> # and the second to the second
>>> rot.apply(np.array([[0, 0, 1.0], [0, 1, 0.0]])).round()
array([[ 0., -1.,  0.],
       [ 0., -1.,  0.]])

Examples using gaitmap.utils.rotations.rotation_from_angle#

MaD DiGait Pipeline

MaD DiGait Pipeline

MaD DiGait Pipeline
Manual Sensor Alignment

Manual Sensor Alignment

Manual Sensor Alignment