# The normal vector to a plane ax+by+cz+d=0?

I am calculating the normal vector to a plane ax+by+cz+d=0

According to the book:

The normal vector N is often normalized to unit length because in that case the equation

d = N ⋅Q + D


gives the signed distance from the plane to an arbitrary point Q. If d = 0, then the point Q lies in the plane. If d > 0, we say that the point Q lies on the positive side of the plane since Q would be on the side in which the normal vector points.

How to get the N (Normal vector)? Thank you

From MathWorld:

Given the plane Then the normal vector is The normal unit vector n is given by: Therefore, for the plane 5x+2y+3z-1=0,

The normal vector N is

N = [5,2,3]

The magnitude |N| is

|N| = sqrt(5^2 + 2^2 + 3^2)

|N| = 6.1644

The normal unit vector n is therefore approximately:

n = N / |N|

n = [0.8111, 0.3244, 0.4866]

which you can check by measuring the length of n.

Code:

import math

def mag(V):
return math.sqrt(sum([x*x for x in V]))
def n(V):
v_m = mag(V)
return [ vi/v_m for vi in V]


In an interactive python shell:

>>> N = [5,2,3]
>>> mag(N)
6.164414002968976
>>> n(N)
[0.8111071056538127, 0.3244428422615251, 0.48666426339228763]
>>> mag(n(N))
1.0