Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
You don't appear to have made a lot of research first, did you? – sam hocevar Apr 21 '12 at 10:51

From MathWorld:

Given the plane

enter image description here

Then the normal vector is

enter image description here

The normal unit vector n is given by:

enter image description here

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.


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)
>>> n(N)
[0.8111071056538127, 0.3244428422615251, 0.48666426339228763]
>>> mag(n(N))
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.