All problems
2D Reflection Matrix Apply
Problem
Reflect a 2D vector v across the line through the origin at angle theta degrees.
The reflection matrix is [[cos(2t), sin(2t)], [sin(2t), -cos(2t)]] with t = radians(theta).
Hint
theta = 0 reflects across the x-axis; theta = 45 swaps coordinates.
Test cases
case 1
in: [[1,1],90]
expected: [-1,1]
case 2
in: [[1,0],0]
expected: [1,0]
case 3
in: [[0,2],0]
expected: [0,-2]
case 4
in: [[1,1],45]
expected: [1,1]
Starter codePython
def reflect_2d(v, theta_degrees):
# Your code here
pass4 test cases · run your code against them in the editor