Matrix Rotation Around a Vector (Axis Angle)

Calculator for rotating a 4x4 matrix around an arbitrary axis

Vector Rotation Calculator

Instructions

Enter the rotation axis vector (X, Y, Z) and the rotation angle. The vector will be automatically normalized. Empty fields are counted as zero.

Rotation Angle
Rotation Axis Vector
Rotation Matrix R(axis, θ)
| |
| |
| |
| |

Axis-Angle Rotation - Overview

What is Axis-Angle Rotation?

Axis-angle rotation (also called Rodrigues' rotation) creates a rotation matrix that rotates points around an arbitrary axis by a specified angle. This is essential for 3D graphics and robotics.

Rodrigues' Rotation Formula

For a normalized axis vector n⃗ = (x, y, z) and angle θ:

\(R = I + \sin(\theta) \cdot K + (1 - \cos(\theta)) \cdot K^2\)

where K is the cross-product matrix of n⃗

Example

Rotation around Z-axis (0,0,1) by 90°:

\(R = \begin{bmatrix}0 & -1 & 0 & 0\\1 & 0 & 0 & 0\\0 & 0 & 1 & 0\\0 & 0 & 0 & 1\end{bmatrix}\)

Key Properties
  • Normalized axis: Vector is automatically normalized
  • Right-hand rule: Positive angle rotates counterclockwise
  • 4×4 matrix: Last row/column for homogeneous coordinates
  • Orthogonal: RT = R-1
  • Determinant: det(R) = 1


Description of Axis-Angle Rotation

Fundamentals

The axis-angle representation defines a rotation by specifying an axis of rotation (as a 3D vector) and an angle of rotation around that axis. This method, formalized by Rodrigues, is widely used in 3D graphics and robotics.

Rodrigues' Formula Components:

For a unit vector n⃗ = (x, y, z) and angle θ, the rotation matrix is:

\(R = I \cos(\theta) + (1 - \cos(\theta)) \mathbf{n} \mathbf{n}^T + \sin(\theta) [\mathbf{n}]_\times\)

where \([\mathbf{n}]_\times\) is the skew-symmetric cross-product matrix:

\([\mathbf{n}]_\times = \begin{bmatrix}0 & -z & y\\z & 0 & -x\\-y & x & 0\end{bmatrix}\)

How It Works
  1. Normalize the axis vector to unit length
  2. Calculate sin(θ) and cos(θ)
  3. Build the cross-product matrix K
  4. Apply Rodrigues' formula: R = I + sin(θ)K + (1-cos(θ))K²
  5. Extend to 4×4 for homogeneous coordinates

Detailed Formula

Complete 3×3 Rotation Matrix:

For normalized axis n⃗ = (x, y, z) and angle θ:

\(R_{11} = \cos\theta + x^2(1-\cos\theta)\)

\(R_{12} = xy(1-\cos\theta) - z\sin\theta\)

\(R_{13} = xz(1-\cos\theta) + y\sin\theta\)

\(R_{21} = yx(1-\cos\theta) + z\sin\theta\)

\(R_{22} = \cos\theta + y^2(1-\cos\theta)\)

\(R_{23} = yz(1-\cos\theta) - x\sin\theta\)

\(R_{31} = zx(1-\cos\theta) - y\sin\theta\)

\(R_{32} = zy(1-\cos\theta) + x\sin\theta\)

\(R_{33} = \cos\theta + z^2(1-\cos\theta)\)

Example: X-Axis Rotation

Axis: (1, 0, 0), Angle: 45°

\(R = \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 0.707 & -0.707 & 0\\ 0 & 0.707 & 0.707 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}\)

4×4 Extension

The 4×4 matrix adds homogeneous coordinates for translations:

\(R_{4\times4} = \begin{bmatrix}R_{3\times3} & \mathbf{0}\\mathbf{0}^T & 1\end{bmatrix}\)

Practical Applications

3D Graphics & Animation:

  • Camera orbit controls around objects
  • Character joint rotations
  • Object orientation in 3D space
  • Gimbal-lock-free rotations

Robotics & Engineering:

  • Robot arm joint control
  • Spacecraft attitude control
  • Mechanical linkage simulation
  • Flight simulator roll/pitch/yaw
Comparison with Other Rotation Methods

Euler Angles:

  • ✓ Intuitive (roll, pitch, yaw)
  • ✗ Gimbal lock problem
  • ✗ Order dependent

Axis-Angle:

  • ✓ No gimbal lock
  • ✓ Compact (4 values)
  • ✗ Not easy to combine

Quaternions:

  • ✓ No gimbal lock
  • ✓ Easy to interpolate
  • ✓ Easy to combine
Key Advantages

Axis-angle representation is particularly useful when you need to rotate around a specific, arbitrary axis. It's more intuitive than quaternions for single rotations and doesn't suffer from gimbal lock like Euler angles. In 3D modeling software, it's common to specify rotations this way (e.g., "rotate 45° around the axis (1,1,0)"). The right-hand rule determines the rotation direction: curl your fingers around the axis with thumb pointing along the axis vector - your fingers show the positive rotation direction.

Right-Hand Rule

Understanding Rotation Direction:

  1. Point your right thumb along the rotation axis
  2. Curl your fingers naturally
  3. Your fingers show the positive rotation direction
  4. A positive angle rotates counterclockwise when viewed from the axis tip

Common Axes:

  • X-axis (1,0,0): Roll - rotate around horizontal
  • Y-axis (0,1,0): Pitch - rotate around vertical
  • Z-axis (0,0,1): Yaw - rotate around depth
  • Custom: Any normalized 3D vector