PIXELBANKv9.1.0
Menu

Rodrigues Rotation Formula

Convert axis-angle representation to a rotation matrix using Rodrigues' formula.

Axis-angle is a compact representation of 3D rotation: a unit axis k\mathbf{k} and angle θ\theta. Rodrigues' formula converts this to a 3×3 rotation matrix:

R=I+sin⁡θ⋅[k]×+(1−cos⁡θ)⋅[k]×2R = I + \sin\theta \cdot [\mathbf{k}]_\times + (1-\cos\theta) \cdot [\mathbf{k}]_\times^2

where [k]×[\mathbf{k}]_\times is the skew-symmetric matrix of axis k=(kx,ky,kz)\mathbf{k} = (k_x, k_y, k_z):

[k]×=(0−kzkykz0−kx−kykx0)[\mathbf{k}]_\times = \begin{pmatrix} 0 & -k_z & k_y \\ k_z & 0 & -k_x \\ -k_y & k_x & 0 \end{pmatrix}

This formula is used extensively in optimization because axis-angle has only 3 parameters (vs. 9 for a rotation matrix) and avoids singularities.

Example:

Input:
rodrigues([0, 0, 1], 1.5708)
Output:
[[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]]
Reasoning:

Rotating 90° (π/2) around Z-axis:

  1. Build skew-symmetric K for axis [0,0,1]: K = [[0, -1, 0], [1, 0, 0], [0, 0, 0]]
  2. Compute K²: K² = [[-1, 0, 0], [0, -1, 0], [0, 0, 0]]
  3. With θ = π/2: sin(θ) ≈ 1, cos(θ) ≈ 0 R = I + 1·K + 1·K² R = [[1,0,0],[0,1,0],[0,0,1]] + K + K² R ≈ [[0,-1,0],[1,0,0],[0,0,1]] This rotates the X-axis to Y-axis (counterclockwise 90°).

Constraints:

  • axis: unit vector [kx, ky, kz] with ||k|| = 1
  • angle: rotation angle in radians
  • Return 3x3 rotation matrix as nested list
solution.py

Test Results

0/0
Run code to see test results.
Rodrigues Rotation Formula - Hard | PixelBank