Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-069

Plane Equation from Three Points

Problem

Return the plane equation [a, b, c, d] for the plane through points p, q, r, where a*x + b*y + c*z + d = 0.

Set [a, b, c] = (q - p) x (r - p) and d = -(a*p[0] + b*p[1] + c*p[2]). Return None if the points are collinear.

Hint

The cross product of two edge vectors is a normal; plug in p to find d.

Test cases

case 1
in: [[0,0,0],[1,0,0],[0,1,0]]
expected: [0,0,1,0]
case 2
in: [[0,0,0],[1,0,0],[0,0,1]]
expected: [0,-1,0,0]
case 3
in: [[1,1,1],[2,1,1],[1,3,1]]
expected: [0,0,2,-2]
case 4
in: [[0,0,0],[1,1,1],[2,2,2]]
expected: null
Starter codePython
def plane_from_points(p, q, r):
    # Your code here
    pass

4 test cases · run your code against them in the editor