Quaternion and Euler Angle Converter

Paste a quaternion, matrix or angles from any engine, read the same rotation in every other form, spot gimbal lock and copy it as three.js, Unity, SciPy or ROS code.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Pick an input

    Type a quaternion, paste four numbers, enter Euler angles, axis-angle or a matrix.

  2. 2
    Set the convention

    Choose the Euler sequence, intrinsic or extrinsic, and degrees or radians.

  3. 3
    Watch the cube

    Check that the rotated axes point where you expect, and drag to adjust.

  4. 4
    Compare conventions

    Open the all-conventions tab to find the order another library uses.

  5. 5
    Interpolate

    Use the slerp tab to see the rotation halfway to a target.

  6. 6
    Copy code

    Choose a library and decimals, then copy or download the snippet.

About this tool

Rotations in 3D can be written in several ways, and every library seems to pick a different one. Game engines store quaternions, robotics stacks talk about roll, pitch and yaw, CAD and physics code uses rotation matrices, and computer vision passes rotation vectors. Converting between them is where bugs hide: the scalar part of a quaternion comes first in some libraries and last in others, Euler angles can be applied about fixed or moving axes in twelve different orders, and some orientations have no unique set of angles at all. This converter keeps one rotation as the source of truth and shows it in every form at once. Edit any representation and the others follow, see the effect on a 3D cube, list the angles for all 24 Euler conventions side by side, interpolate between two rotations with slerp, and copy the result as code for the library you use.

The four representations

A unit quaternion has four numbers w, x, y and z with w² + x² + y² + z² = 1; q and -q describe the same rotation, so the tool shows the form with w ≥ 0. A rotation matrix is a 3 by 3 orthonormal matrix with determinant 1 that turns a column vector v into R v. Axis-angle names a unit axis and an angle about it, and the rotation vector used by OpenCV is that axis multiplied by the angle in radians. Euler angles are three successive rotations about coordinate axes.

Intrinsic or extrinsic, and which order

Intrinsic angles rotate about the body's own axes, which move after each step; extrinsic angles rotate about the fixed world axes. Intrinsic X then Y then Z equals extrinsic Z then Y then X with the same three angles, which is the usual reason two libraries disagree. Tait-Bryan sequences use three different axes (XYZ, ZYX and so on); proper Euler sequences repeat the first axis (ZXZ, ZYZ and others) and are common in physics and crystallography. The all-conventions tab prints the same rotation in all twelve orders, both ways.

Gimbal lock

For Tait-Bryan angles, when the middle angle reaches ±90 degrees the first and third axes line up and only their sum or difference is defined. For proper Euler sequences the same happens at 0 or 180 degrees. The converter detects this case, says so, sets the first angle to zero and puts the whole remaining rotation on the third axis, so the matrix and quaternion are still exact.

Matrix input and checks

Paste nine numbers row by row. If the matrix is not quite orthonormal, for example after rounding, the tool reports the orthogonality error and determinant and uses the nearest quaternion found by Shepperd's method. A determinant of -1 means a reflection, not a rotation.

Code output

Choose three.js, Unity, Unreal, GLM, Eigen, SciPy, ROS YAML, NumPy, MATLAB or JSON. Each template puts the scalar where that library expects it: three.js, Unity, Unreal, SciPy and ROS use x, y, z, w, while GLM and Eigen constructors take w first.

Limits

All conventions here are right-handed and active (the object rotates, not the frame). Left-handed engines such as Unity flip some signs relative to textbook formulas, so compare with a known test rotation before you trust a pipeline. Angles are wrapped to -180 to 180 degrees, which is not the only valid choice. The cube preview is a fixed-camera sketch, not a full 3D viewer.

Worked example

A drone reports yaw 30°, pitch 45° and roll 60° as intrinsic ZYX angles. The converter turns that into the quaternion w 0.822, x 0.360, y 0.440, z 0.022 and a matrix whose first column, the drone's forward axis, is (0.612, 0.354, -0.707). The same rotation as intrinsic XYZ angles is about 58.3°, 47.7° and -24.6°, which is what an engine using that order would expect. Copying it as three.js gives new THREE.Quaternion(0.360, 0.440, 0.022, 0.822) with the scalar last.

Quick facts

Frequently asked questions

Why do my Euler angles come out different from another tool?

Check the order and whether it is intrinsic or extrinsic. Intrinsic XYZ equals extrinsic ZYX, and many tools differ only in this. The all-conventions tab shows every combination.

Is the quaternion w first or last?

Both conventions exist. The paste box lets you choose; the code tab writes the order each library expects.

What is gimbal lock?

A pose where the middle Euler angle makes two rotation axes coincide, so infinitely many angle sets give the same rotation. Quaternions and matrices have no such problem.

Why is my quaternion changed when I press normalise?

Only unit quaternions are rotations. Normalising divides by the length; the direction of rotation stays the same.

Can I use radians?

Yes. Untick Degrees and every angle field and table switches to radians.

Does the tool handle left-handed coordinates?

It uses right-handed active rotations. For a left-handed engine, convert axes first or compare with a test rotation, and the FAQ above about different results applies.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages