ktk.geometry.get_angles#

get_angles(T, seq, degrees=False, flip=False)[source]#

Extract Euler angles from a series of homogeneous matrices.

In case of gimbal lock, a warning is raised, and the third angle is set to zero. Note however that the returned angles still represent the correct rotation.

Parameters
  • T (ArrayLike) – An Nx4x4 series of transformation matrices.

  • seq (str) – 3 characters belonging to the set {“X”, “Y”, “Z”} for intrinsic rotations (moving axes), or {“x”, “y”, “z”} for extrinsic rotations (fixed axes). Adjacent axes cannot be the same. Extrinsic and intrinsic rotations cannot be mixed in one function call.

  • degrees (bool) – If True, the returned angles are in degrees. If False, they are in radians. Default is False.

  • flip (bool) – Return an alternate sequence with the second angle inverted, but that leads to the same rotation matrices. See below for more information.

Returns

An Nx3 series of Euler angles, with the second dimension containing the first, second and third angles, respectively.

Return type

np.ndarray

Notes

The range of the returned angles is dependant on the flip parameter. If flip is False:

  • First angle belongs to [-180, 180] degrees (both inclusive)

  • Second angle belongs to:

    • [-90, 90] degrees if all axes are different. e.g., xyz

    • [0, 180] degrees if first and third axes are the same e.g., zxz

  • Third angle belongs to [-180, 180] degrees (both inclusive)

If flip is True:

  • First angle belongs to [-180, 180] degrees (both inclusive)

  • Second angle belongs to:

    • [-180, -90], [90, 180] degrees if all axes are different. e.g., xyz

    • [-180, 0] degrees if first and third axes are the same e.g., zxz

  • Third angle belongs to [-180, 180] degrees (both inclusive)

This function is a wrapper for scipy.transform.Rotation.as_euler. Please consult scipy help for more help on intrinsic/extrinsic angles and the seq parameter.