All problems
2D Rotation Matrix Apply
Problem
Rotate a 2D vector v counterclockwise by theta degrees about the origin.
Use x' = x*cos(t) - y*sin(t) and y' = x*sin(t) + y*cos(t), with t = radians(theta).
Hint
Remember to convert degrees to radians before calling sin/cos.
Test cases
case 1
in: [[1,0],90]
expected: [0,1]
case 2
in: [[1,0],180]
expected: [-1,0]
case 3
in: [[2,3],0]
expected: [2,3]
case 4
in: [[1,1],45]
expected: [0,1.414213562373095]
Starter codePython
def rotate_2d(v, theta_degrees):
# Your code here
pass4 test cases · run your code against them in the editor