v9.1.1
Menu

Rodrigues Rotation Formula

hardFREEPose EstimationPoseCV: Structure from Motion and SLAM

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
  • Inputs: axis is k=(0,0,1)\mathbf{k} = (0, 0, 1), the unit zz axis; angle is θ=1.5708≈π/2\theta = 1.5708 \approx \pi/2 radians.
  • Skew matrix: with kx=ky=0k_x = k_y = 0 and kz=1k_z = 1, [k]×[\mathbf{k}]_\times has rows (0,−1,0)(0, -1, 0), (1,0,0)(1, 0, 0), (0,0,0)(0, 0, 0). Its square is diagonal with entries (−1,−1,0)(-1, -1, 0).
  • Coefficients: sin⁡θ≈1\sin\theta \approx 1 and cos⁡θ≈−3.67×10−6\cos\theta \approx -3.67 \times 10^{-6}, so 1−cos⁡θ≈11 - \cos\theta \approx 1.
  • Sum: I+[k]×+[k]×2I + [\mathbf{k}]_\times + [\mathbf{k}]_\times^2. The diagonal becomes 1−1=01 - 1 = 0, 1−1=01 - 1 = 0 and 1+0=11 + 0 = 1; the skew part adds −1-1 at row 1, column 2 and +1+1 at row 2, column 1, giving [[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]].
  • Output: a 3×33 \times 3 nested list of floats, shown rounded; the raw diagonal is really cos⁡θ≈−3.67×10−6\cos\theta \approx -3.67 \times 10^{-6} since 1.5708 is not exactly π/2\pi/2.
  • Notice the first column (0,1,0)(0, 1, 0): the xx axis lands on the yy axis (counterclockwise 90°), while the zz column is untouched: points on the axis never move.

Constraints

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

Learn this in

More from CV: Structure from Motion and SLAM

solution.py

Test results

Sign in to run your code against the test cases.