All problems
Reflect Vector across Plane
Problem
Reflect vector v across the plane through the origin with normal n.
The reflection flips the normal component:
v - 2 * ((v . n) / (n . n)) * n
Return None if n is the zero vector.
Hint
A reflection is the identity minus twice the projection onto the normal.
Test cases
case 1
in: [[1,2,3],[0,0,1]]
expected: [1,2,-3]
case 2
in: [[2,0,0],[1,0,0]]
expected: [-2,0,0]
case 3
in: [[1,-1,5],[1,1,0]]
expected: [1,-1,5]
case 4
in: [[1,2,3],[0,0,0]]
expected: null
case 5
in: [[1,1,1],[0,1,1]]
expected: [1,-1,-1]
Starter codePython
def reflect_across_plane(v, n):
# Your code here
pass5 test cases · run your code against them in the editor