Rotation Matrix Calculator
Online calculator to convert Euler angles to a rotation matrix
XYZ Axis Rotation Calculator
Instructions
This function calculates the 3D rotation of a body/vector with Euler angles according to the ZYX convention.
- Unit: Switch between degrees and radians
- Mode: Active (rotate object) or Passive (rotate coordinates)
Euler Angles - Overview
3D Rotation
A 3D object can be rotated around three axes. These rotations are known as Yaw, Pitch, and Roll. This calculator uses the ZYX convention (Euler angles).
Rotation Axes
- Yaw (α, Z-axis): Rotation around Z-axis
- Pitch (β, Y-axis): Rotation around Y-axis
- Roll (γ, X-axis): Rotation around X-axis
Gimbal Lock Warning
A problem with rotation using 3 angles is when a configuration is created in which 2 axes of rotation are superimposed. With the ZYX convention, this occurs when the pitch angle is 90°. This condition is called "gimbal lock" and must be prevented. For this reason, rotation with quaternions is often preferred.
Rotation Modes
- Active Rotation: The vector/object is rotated in the coordinate system (counterclockwise). Also called geometric transformation.
- Passive Rotation: The coordinate system is rotated (clockwise). The vector remains unchanged.
|
Matrix Rotation Around Z, Y and X Axes
Active Rotation
With the active rotation, the vector or the object is rotated in the coordinate system. The active rotation is also called geometric transformation. The rotation is counterclockwise.
Example: 90° Rotation (Z-axis, counterclockwise)
\(R_z(\alpha)= \begin{bmatrix}1 & 0 & 0\\ 0 & \cos \alpha & -\sin \alpha \\0 & \sin \alpha & \cos \alpha\end{bmatrix} = \begin{bmatrix}1 & 0 & 0 \\ 0 & 0 & -1 \\ 0 & 1 & 0\end{bmatrix}\)
Passive Rotation
With passive rotation, the coordinate system is rotated. The vector remains unchanged. The rotation is clockwise.
Example: 90° Rotation (Z-axis, clockwise)
\(R_z^{-1}(\alpha)= \begin{bmatrix}1 & 0 & 0 \\ 0 & \cos \alpha & \sin \alpha \\0 & -\sin \alpha & \cos \alpha\end{bmatrix} = \begin{bmatrix}1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & -1 & 0\end{bmatrix}\)
Yaw, Pitch, Roll Rotation
Yaw (Z-axis)
Yaw denotes counterclockwise rotation of the Z axis:
\(R_z(\alpha)= \begin{bmatrix}1 & 0 & 0 \\ 0 & \cos \alpha & -\sin \alpha \\ 0 & \sin \alpha & \cos \alpha\end{bmatrix}\)
Pitch (Y-axis)
Pitch refers to the counterclockwise rotation of the Y-axis:
\(R_y(\beta)= \begin{bmatrix}\cos \beta & 0 & \sin \beta \\ 0 & 1 & 0 \\ -\sin \beta & 0 & \cos \beta\end{bmatrix}\)
Roll (X-axis)
Roll is the counterclockwise rotation of the X-axis:
\(R_x(\gamma)= \begin{bmatrix}\cos \gamma & -\sin \gamma & 0 \\ \sin \gamma & \cos \gamma & 0 \\0 & 0 & 1\end{bmatrix}\)
Formula for Yaw, Pitch, Roll Rotation
Each rotation matrix is a simple extension of the 2D rotation matrix. The yaw, pitch and roll rotations can be used to place a 3D body in any direction. A single rotation matrix can be formed by multiplying the matrices.
\(R(\alpha\beta\gamma) = R_z(\alpha) \cdot R_y(\beta) \cdot R_x(\gamma) =\)
\(\begin{bmatrix} \cos \alpha \cdot \cos \beta & \cos \alpha \cdot \sin \beta \cdot \sin \gamma - \sin \alpha \cdot \cos \gamma & \cos \alpha \cdot \sin \beta \cdot \cos \gamma + \sin \alpha \cdot \sin \gamma \\ \sin \alpha \cdot \cos \beta & \sin \alpha \cdot \sin \beta \cdot \sin \gamma + \cos \alpha \cdot \cos \gamma & \sin \alpha \cdot \sin \beta \cdot \cos \gamma - \cos \alpha \cdot \sin \gamma \\ -\sin \beta & \cos \beta \cdot \sin \gamma & \cos \beta \cdot \cos \gamma \end{bmatrix}\)
Practical Applications
Aerospace & Robotics:
- Aircraft attitude control
- Drone navigation systems
- Robotic arm positioning
- Satellite orientation
Computer Graphics & Gaming:
- 3D object rotation
- Camera orientation
- Character animation
- Virtual reality systems
Gimbal Lock Problem
A problem with the rotation with 3 angles is when a configuration is created in which 2 axes of rotation are superimposed. With the ZYX convention, a problem arises when setting a pitch angle of 90°. Then both roll and yaw are the same movement, but this does not cause any change in attitude.
This condition is called "gimbal lock" and must be prevented. For this reason rotation with the quaternion is often preferred. Rotation with quaternions can be found here.