All problems
Reflection Matrix across Plane
Problem
Build the 3x3 reflection matrix across the plane through the origin with normal n:
H = I - 2 * (n n^T) / (n . n)
Return None if n is the zero vector.
Hint
The matrix is symmetric and satisfies H*H = I, so it is its own inverse.
Test cases
case 1
in: [[0,0,1]]
expected: [[1,0,0],[0,1,0],[0,0,-1]]
case 2
in: [[1,0,0]]
expected: [[-1,0,0],[0,1,0],[0,0,1]]
case 3
in: [[1,1,1]]
expected: [[0.33333333333333337,-0.6666666666666666,-0.6666666666666666],[-0.6666666666666666,0.33333333333333337,-0.6666666666666666],[-0.6666666666666666,-0.66666666666…
case 4
in: [[0,0,2]]
expected: [[1,0,0],[0,1,0],[0,0,-1]]
case 5
in: [[0,0,0]]
expected: null
Starter codePython
def reflection_matrix_plane(n):
# Your code here
pass5 test cases · run your code against them in the editor