Skip to content

Conversion between quaternions and Euler angles

A convention-bound transformation between a normalized unit quaternion and an ordered Euler-angle parameterization representing the same three-dimensional rotation.

Version
v1 · 2026-09-28 · History
Domain-specific #
8706
Domain group
Formal Sciences
Origin domain
Mathematics
Subdomains
Rotation Representations, Quaternion Algebra → Mathematics

Core Idea

Conversion between quaternions and Euler angles transforms two parameterizations of the same proper three-dimensional rotation. The source Euler representation supplies three ordered axis rotations; the quaternion representation supplies four normalized components. Correct formulas are inseparable from conventions: axis sequence, intrinsic or extrinsic rotation, active or passive interpretation, handedness, angle units, quaternion component order, and multiplication direction.

A unit quaternion has norm one, and q and −q encode the same rotation. Euler angles are generally nonunique and have singular configurations, commonly called gimbal lock, where two rotational degrees of freedom become indistinguishable in that parameterization. Conversion must preserve rotation action rather than raw parameter equality.

Operationally, Rotation convention fixes frames, handedness, active/passive meaning, and units. Euler sequence supplies ordered axes and intrinsic or extrinsic composition. Unit quaternion supplies normalized scalar and vector components under a declared layout. Forward conversion composes half-angle rotations into a quaternion. Inverse conversion uses quadrant-aware branches and singular handling. Equivalence test verifies equal rotated vectors or matrices, including q ≡ −q.

How would you explain it like I'm…

Two Ways to Say a Turn

There are two ways to tell someone how to turn a toy airplane. One way: 'turn it this much, then tip it this much, then roll it this much', three turns in order. The other way uses four special numbers that describe the whole turn at once. Converting means changing one kind of instructions into the other so the airplane ends up facing exactly the same way.

Same Turn, Different Numbers

Computers and robots need to describe how things are turned in 3D. Euler angles describe a turn as three turns around certain axes, done in a certain order. Quaternions describe the same turn with four numbers that follow special rules. Converting between them means finding the other description of the exact same turn. The tricky part is that people use different rules, like which order the three turns go in, so the math only works if you know the rules. Also, some turns can be described in more than one way, and at certain positions Euler angles get stuck, a problem called gimbal lock.

Rotation Parameterization Conversion

Rotations in 3D can be written in different ways. Euler angles describe a rotation as three turns about axes in a set order. A unit quaternion describes it with four numbers whose squares add up to one. Converting between them means finding the parameters in one system that produce exactly the same rotation as the other. The formulas depend completely on conventions: the order of axes, whether each turn is about fixed or moving axes (extrinsic or intrinsic), whether the rotation moves the object or the coordinate frame, handedness, degrees or radians, the order the quaternion's components are listed in, and the multiplication order. The descriptions aren't one-to-one: q and -q give the same rotation, and Euler angles can have several solutions and break down at 'gimbal lock', where two of the three turns become indistinguishable. So a correct conversion matches what the rotation does, not the raw numbers.

 

Conversion between quaternions and Euler angles maps between two parameterizations of the same proper rotation in three dimensions. An Euler representation supplies three angles for an ordered sequence of axis rotations; a unit quaternion supplies four components with norm one. Correct formulas cannot be separated from conventions: the axis sequence, intrinsic versus extrinsic composition, active versus passive interpretation, handedness, angle units, quaternion component order (scalar first or last), and multiplication direction. Getting any one wrong gives a formula that looks plausible but encodes a different rotation. Neither parameterization is one-to-one: q and -q represent the same rotation (a double cover), and Euler angles are generally nonunique and have singular configurations, known as gimbal lock, in which two rotational degrees of freedom become indistinguishable, so the inverse map is ill-conditioned or undefined there. The correctness criterion is therefore preservation of the rotation's action on vectors, not equality of parameter values. Round-tripping tests must compare rotations, accounting for the sign ambiguity of q and the Euler singularities.

Scope of Application

The conversion is used in robotics, aerospace, navigation, simulation, computer graphics, biomechanics, and sensor fusion. Interfaces between libraries are especially vulnerable because different systems order quaternion components or compose rotations differently.

It is not quaternion interpolation, conversion of an arbitrary four-vector, or a generic coordinate-frame transformation with unstated active/passive meaning. A triple labeled “roll, pitch, yaw” is insufficient without its sequence and frame convention. Component equality is not the correct validation because quaternions double-cover rotations and Euler triples are nonunique.

Illustrative cases include: A declared intrinsic ZYX active rotation is composed into a normalized Hamilton-order quaternion and verified by rotating the same basis vectors. A sensor quaternion is converted to display angles with an explicit singular fallback, then converted back and compared modulo quaternion sign.

Clarity

The abstraction turns “convert orientation” into a complete contract. It explains why two implementations can each cite correct-looking formulas yet disagree, and why singularity is a property of the Euler chart rather than physical loss of orientation.

Manages Complexity

Many convention choices are compressed into one typed conversion. Declaring them once lets formulas and tests remain compact. The conversion manages representational complexity but does not remove Euler nonuniqueness or quaternion sign equivalence.

Abstract Reasoning

Declare source and target conventions. Normalize the input quaternion or validate the Euler sequence. For Euler-to-quaternion conversion, compose the appropriate half-angle factors in the declared order. For the inverse, use atan2, clamp roundoff-sensitive inverse-trigonometric inputs, choose branches, and define singular fallback. Verify by converting both representations to rotation matrices or applying them to basis vectors, then run round-trip tests modulo equivalence.

Knowledge Transfer

The workflow transfers across software stacks only after convention adapters are written. Numerical formulas do not transfer unchanged between Hamilton and alternate layouts, active and passive rotations, or different axis orders. The broader lesson is that conversion among nonunique representations must preserve the represented transformation, not the coordinate tuple.

Relationships to Other Abstractions

Local relationship map for Conversion between quaternions and Euler anglesParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Conversion between q…DOMAINPrime abstraction: Transformation — is a kind ofTransformationPRIME

Current abstraction Conversion between quaternions and Euler angles Domain-specific

Parents (1) — more general patterns this builds on

  • Conversion between quaternions and Euler angles is a kind of Transformation Prime

    Conversion between quaternions and Euler angles is a strict kind of Transformation: its frozen identity entails the parent's defining structure while adding domain-specific restrictions.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Conversion between quaternions and Euler angles sits in a sparse region of the domain-specific corpus (96th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.

Family — Unclustered & Miscellaneous (2551 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-10-08