Quaternion to Euler angles converter
Paste the four components of a rotation quaternion to get its roll, pitch and yaw, or switch the direction to turn three Euler angles into a quaternion. The converter uses the common Z-Y-X (yaw, pitch, roll) convention of aircraft, robots and many game engines.
Runs in your browser: nothing you enter is sent anywhere.
How to use
- Choose Quaternion → Euler or Euler → quaternion.
- Enter w, x, y and z, or roll, pitch and yaw in degrees.
- Read the result; for quaternion input the length of what you typed is shown too.
From a unit quaternion (w, x, y, z):
- roll = atan2(2(wx + yz), 1 − 2(x² + y²))
- pitch = asin(2(wy − zx)), limited to ±90°
- yaw = atan2(2(wz + xy), 1 − 2(y² + z²))
Back from angles, with c and s the cosine and sine of half of each angle:
- w = c_r c_p c_y + s_r s_p s_y, x = s_r c_p c_y − c_r s_p s_y
- y = c_r s_p c_y + s_r c_p s_y, z = c_r c_p s_y − s_r s_p c_y
Example
The quaternion (0.9238795, 0, 0, 0.3826834) is cos 22.5° and sin 22.5° about Z. Yaw = atan2(2 × 0.92388 × 0.38268, 1 − 2 × 0.38268²) = atan2(0.70711, 0.70711) = 45°, roll and pitch are 0°: a 45° turn to the left about the vertical axis.
The other way, pitch 90° alone gives w = cos 45° = 0.707107 and y = sin 45° = 0.707107, with x and z equal to 0.
Tips
- q and −q are the same rotation; if a library returns negative w, the angles are still correct.
- Angles above 180° are wrapped: the converter returns roll and yaw between −180° and 180°.
- For lists of rotations, check one pair here before you write the conversion in code.
Frequently asked questions
Which rotation order does the converter use?
Z-Y-X intrinsic: first yaw about Z, then pitch about the new Y, then roll about the new X — the Tait-Bryan angles used in aviation, ROS and most physics texts. Other orders (for example Unity's Z-X-Y) give different angles for the same quaternion.
Why is my quaternion normalised?
Only unit quaternions describe pure rotations. Rounded values such as 0.7071 are slightly off, so the converter divides by the length first and shows that length. A length far from 1 usually means a typo.
What happens at pitch ±90°?
That is gimbal lock: roll and yaw turn about the same axis and only their difference matters. The converter clamps pitch to ±90° and returns one valid pair of roll and yaw, which may differ from the angles you started with but gives the same orientation.
In which order are the components written?
Here the scalar part w comes first: (w, x, y, z). Some libraries, such as Unity and three.js, store (x, y, z, w). Check your source and type the scalar into the w field.