# shz_quat_to_angles_zyx

Source: https://sh4zam.com/api/quat/shz_quat_to_angles_zyx/

```c
SHZ_INLINE shz_vec3_t shz_quat_to_angles_zyx(shz_quat_t q) SHZ_NOEXCEPT;
```

Decomposes the given quaternion into Z, Y, then X Tait-Bryan angles.

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `q` | `shz_quat_t` | Unit quaternion to decompose. |

## Returns

The Z, Y, and X angles of rotation, in radians.

## Details

Returns the angles a, b, and c, in radians, such that the given quaternion is equal to Qz(a) \* Qy(b) \* Qx(c), making this the inverse of `shz_quat_from_rotation_zyx()`. The angles are returned in the same order as that routine takes them: x = Z angle, y = Y angle, z = X angle.

The outer angles are in \[-PI, PI\] and the middle angle is in \[-PI/2, PI/2\].

## Notes

- At gimbal lock, when the middle angle is +/-PI/2, the outer angles are not unique. The returned angles still reconstruct the same rotation.

## Availability

- **C++ equivalent:** [`shz::quat::to_angles_zyx`](https://sh4zam.com/api/cpp/quat/#to_angles_zyx)
- **Type-generic form:** none
- **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation
- **Defined in:** [`sh4zam/shz_quat.h:205`](https://github.com/gyrovorbis/sh4zam/blob/6b22b851ad9ca109049f956dbbbecf7c519c959f/include/sh4zam/shz_quat.h#L205)
- **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties"

## See also

[`shz_quat_from_rotation_zyx`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zyx/), [`shz_quat_to_angles_xyz`](https://sh4zam.com/api/quat/shz_quat_to_angles_xyz/)
