All problems
Distance from Point to Plane
Problem
Compute the distance from point p to the plane through point q with normal vector n:
d = |n . (p - q)| / ||n||_2
If n is the zero vector, return None.
Hint
Project p - q onto the unit normal and take the absolute value.
Test cases
case 1
in: [[1,2,3],[0,0,1],[0,0,0]]
expected: 3
case 2
in: [[1,1,1],[1,1,1],[0,0,0]]
expected: 1.7320508075688774
case 3
in: [[4,0,0],[2,0,0],[1,0,0]]
expected: 3
case 4
in: [[1,1,1],[0,0,0],[0,0,0]]
expected: null
Starter codePython
def point_plane_distance(p, n, q):
# Your code here
pass4 test cases · run your code against them in the editor