All problems
Rotation Matrix from Angle
Problem
Build the 2x2 counterclockwise rotation matrix for theta degrees:
R = [[cos(t), -sin(t)], [sin(t), cos(t)]]
with t = radians(theta).
Hint
The matrix is orthogonal with determinant 1.
Test cases
case 1
in: [90]
expected: [[0,-1],[1,0]]
case 2
in: [0]
expected: [[1,0],[0,1]]
case 3
in: [180]
expected: [[-1,0],[0,-1]]
case 4
in: [45]
expected: [[0.7071067811865476,-0.7071067811865476],[0.7071067811865476,0.7071067811865476]]
Starter codePython
def rotation_matrix_2d(theta_degrees):
# Your code here
pass4 test cases · run your code against them in the editor