newton.math.quat_decompose#

newton.math.quat_decompose(q)[source]#

Decompose a quaternion into wrapped XYZ Euler coordinates.

This wrapper calls wp.quat_to_euler() with the Newton convention \((i, j, k) = (2, 1, 0)\), then wraps each angle to the principal branch. Wrapping avoids equivalent representations that differ by \(2\pi\), which improves stability when reconstructing joint coordinates.

\[e = \operatorname{quat\_to\_euler}(q, 2, 1, 0),\quad e_i \leftarrow \operatorname{wrap}_{[-\pi,\pi)}(e_i)\]
Parameters:

q (quatf) – Input quaternion in Warp layout (x, y, z, w).

Returns:

Wrapped Euler coordinates (x, y, z) [rad].

Return type:

wp.vec3