All problems
Rodrigues Rotation Matrix
Problem
Build the 3x3 rotation matrix for rotating by theta degrees around the axis a, using Rodrigues' formula:
R = I + sin(t)*K + (1 - cos(t))*K^2
where t = radians(theta), a is normalized, and K is the cross-product matrix of a. Return None if a is the zero vector.
Hint
The cross-product matrix K satisfies K*v = a x v.
Test cases
case 1
in: [[0,0,1],90]
expected: [[0,-1,0],[1,0,0],[0,0,1]]
case 2
in: [[1,0,0],180]
expected: [[1,0,0],[0,-1,0],[0,0,-1]]
case 3
in: [[0,1,0],0]
expected: [[1,0,0],[0,1,0],[0,0,1]]
case 4
in: [[0,0,1],180]
expected: [[-1,0,0],[0,-1,0],[0,0,1]]
Starter codePython
def rodrigues_rotation(axis, theta_degrees):
# Your code here
pass4 test cases · run your code against them in the editor