Quaternion from Euler Angles

Convert yaw, pitch and roll into a quaternion

Euler to Quaternion Converter

Euler angles to quaternion

Convert the three Euler angles Yaw (Y), Pitch (X) and Roll (Z) into a quaternion representation

Euler conversion

Conversion uses trigonometric functions of the half angles: cos(α/2) and sin(α/2) for each Euler angle

Enter Euler angles (Yaw, Pitch, Roll)
Rotation angles
Rotation about the vertical Y-axis
Rotation about the horizontal X-axis
Rotation about the longitudinal Z-axis
Settings
Quaternion conversion result
W (rotation):
X (i comp.):
Y (j comp.):
Z (k comp.):
Conversion: Euler angles (Yaw, Pitch, Roll) → Quaternion (w, x, y, z)

Euler angles info

Euler angles

Yaw: Y-axis (left/right)
Pitch: X-axis (up/down)
Roll: Z-axis (spin)

Intuitive Gimbal Lock 3 angles → 4 components

Advantage: intuitive rotation representation
Use: robotics, aerospace, gaming

Rotation order
1. Yaw (Y-axis)
2. Pitch (X-axis)
3. Roll (Z-axis)

Formulas for Euler to quaternion conversion

General conversion formulas
\[\begin{align} c_y &= \cos(\text{yaw}/2), \quad s_y = \sin(\text{yaw}/2) \\ c_p &= \cos(\text{pitch}/2), \quad s_p = \sin(\text{pitch}/2) \\ c_r &= \cos(\text{roll}/2), \quad s_r = \sin(\text{roll}/2) \end{align}\]

Trigonometric functions of the half angles

Quaternion components
\[\begin{align} w &= c_y \cdot c_p \cdot c_r + s_y \cdot s_p \cdot s_r \\ x &= c_y \cdot s_p \cdot c_r - s_y \cdot c_p \cdot s_r \\ y &= s_y \cdot c_p \cdot c_r + c_y \cdot s_p \cdot s_r \\ z &= c_y \cdot c_p \cdot s_r - s_y \cdot s_p \cdot c_r \end{align}\]

Complete quaternion calculation

Rotation matrix equivalent
\[R = R_z(\text{roll}) \cdot R_x(\text{pitch}) \cdot R_y(\text{yaw})\]

Corresponding rotation matrix chain

Compact notation
\[q = q_y \cdot q_p \cdot q_r\] \[\text{with } q_y = [\cos(\text{yaw}/2), 0, \sin(\text{yaw}/2), 0]\] \[q_p = [\cos(\text{pitch}/2), \sin(\text{pitch}/2), 0, 0]\] \[q_r = [\cos(\text{roll}/2), 0, 0, \sin(\text{roll}/2)]\]

As product of individual quaternions

Examples for Euler to quaternion conversion

Example 1: Simple rotations
Yaw = 30° Pitch = 50° Roll = 20°
Step 1: Compute half angles \[\text{yaw}/2 = 15°, \text{pitch}/2 = 25°, \text{roll}/2 = 10°\] Step 2: Trigonometric values \[\cos(15°) \approx 0.966, \sin(15°) \approx 0.259\] \[\cos(25°) \approx 0.906, \sin(25°) \approx 0.423\] \[\cos(10°) \approx 0.985, \sin(10°) \approx 0.174\]

Complex computation with many terms

Example 2: Pure yaw rotation
Yaw = 90° Pitch = 0°, Roll = 0°
\[\begin{align} w &= \cos(45°) = \frac{\sqrt{2}}{2} ≈ 0.707 \\ x &= 0 \\ y &= \sin(45°) = \frac{\sqrt{2}}{2} ≈ 0.707 \\ z &= 0 \end{align}\]

q = 0.707 + 0i + 0.707j + 0k

Practical applications
Aircraft navigation
Pitch, Yaw, Roll
Robot control
Joint orientation
3D animation
Object rotation
VR/AR
Head tracking

Euler angles are intuitive, but quaternions avoid gimbal lock and are more efficient

Step-by-step guide
Preparation
  1. Enter Euler angles in desired unit
  2. Observe rotation order (Y-X-Z)
  3. Divide angles by 2 for half angles
  4. Compute trigonometric values
Execution
  1. W component: compute product term
  2. X component: pitch-dominant term
  3. Y component: yaw-dominant term
  4. Z component: roll-dominant term

Applications of Euler to quaternion conversion

Conversion from Euler angles to quaternions is indispensable in many fields:

Aerospace
  • Flight attitude control: autopilot systems
  • Satellite orientation: attitude control
  • Drone navigation: stabilization
  • Rocket launch sequences: trajectory corrections
Robotics & Automation
  • Industrial robots: joint orientation
  • Humanoid robots: balance and movement
  • Camera gimbals: stabilization
  • Mobile robots: navigation
3D Graphics & Gaming
  • Character animation: bone rotation
  • Camera control: first-person shooters
  • Object manipulation: 3D editors
  • Physics engines: rigid body dynamics
VR/AR & Motion Capture
  • Head tracking: VR headsets
  • Hand tracking: gesture control
  • Motion capture: film production
  • Augmented reality: object placement

Euler angles to quaternions: overcome gimbal lock

Conversion from Euler angles to quaternions is a fundamental operation in 3D rotation theory. While Euler angles (Yaw, Pitch, Roll) are intuitive and easy to understand, they suffer from gimbal lock. Quaternions provide an elegant solution: they are singularity-free, enable smooth interpolation and are computationally efficient. The conversion uses trigonometric functions of the half angles and is particularly important in robotics, aerospace and 3D computer graphics.

Summary

Euler to quaternion conversion connects intuitive Euler angles with the mathematically robust quaternion representation. This transformation is essential for applications that require both human-friendly input and numerical stability. From flight control to robotics and VR, this conversion enables integration between user-facing formats and efficient rotation computations.

More Quaternion Functions

Addition  •  Subtraction  •  Division  •  Multiplication  •  Concatenate  •  Length  •  Interpolation  •  Normalize  •  Scalar Multiplication  •  Dot Product  •  Yaw-Pitch-Roll  •  Conjugates  •  Inverse  •  Negation  •