to_euler#

Quaternion.to_euler(sequence, extrinsic=False)#

Converts the quaternion to Euler angles using the specified rotation sequence.

The conversion follows the method described in [1]. In degenerate (gimbal lock) cases, the third angle is set to zero for stability.

Parameters:
sequencestr

A three-character string indicating the rotation axis sequence (e.g., “xyz” or “ZYX”). It is case-insensitive and must contain only the characters ‘x’, ‘y’, or ‘z’.

extrinsicbool, optional

If True, the rotation is treated as extrinsic. If False (default), it is treated as intrinsic.

Returns:
tuple of float

A tuple of three Euler angles representing the same rotation as the quaternion. Angle in radians.

References

[1] https://doi.org/10.1371/journal.pone.0276302 [2] https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

Examples

>>> from ansys.aedt.core.generic.quaternion import Quaternion
>>> q = Quaternion(0.9069661433330367, -0.17345092325178477, -0.3823030778615049, -0.03422789400943274)
>>> q.to_euler("zxz")
(-2.0344439357957027, 0.8664730673456006, 1.9590019609437583)
>>> q.to_euler("zyz")
(2.677945044588987, 0.8664730673456006, -2.7533870194409316)