All problems
Angle from Rotation Matrix
Problem
Recover the rotation angle in degrees from a 2D rotation matrix R:
theta = degrees(atan2(R[1][0], R[0][0]))
The result lies between -180 and 180 degrees.
Hint
atan2 uses the sign of both components, so it distinguishes clockwise from counterclockwise.
Test cases
case 1
in: [[[1,0],[0,1]]]
expected: 0
case 2
in: [[[0,-1],[1,0]]]
expected: 90
case 3
in: [[[-1,0],[0,-1]]]
expected: 180
case 4
in: [[[0.7071067811865476,0.7071067811865476],[-0.7071067811865476,0.7071067811865476]]]
expected: -45
Starter codePython
def rotation_angle(R):
# Your code here
pass4 test cases · run your code against them in the editor