views:

236

answers:

3

I have a set of points and I can derive a least squares solution in the form z = Ax + By + C. The coefficients I compute are correct but how would I get the vector normal to the plane in an equation of this form? Simply using A B and C coefficients from this equation don't seem correct as a normal vector using my test dataset.

Thanks in advance,

+1  A: 

Form the two vectors

v1 = <1 0 A>
v2 = <0 1 B>

both of which lie in the plane and take the cross-product:

N = v1 x v2 = <-A, -B, +1>     (or    v2 x v1 = <A, B, -1>  )

It works because the cross-product of two vectors is always perpendicular to both of the inputs. So using two (non-colinear) vectors in the plane gives you a normal.

NB: You probably want a normalized normal, of course, but I'll leave that as an exercise.

dmckee
+1  A: 

Following on from dmckee's answer:

a x b = (a2b3 − a3b2), (a3b1 − a1b3), (a1b2 − a2b1)

In your case a1=1, a2=0 a3=A b1=0 b2=1 b3=B

so = (-A), (-B), (1)

Martin Beckett
wolfsnipes
+1  A: 

A little extra color on the dmckee answer. I'd comment directly, but I do not have enough SO rep yet. ;-(

The plane z = Ax + By + C only contains the points (1, 0, A) and (0, 1, B) when C=0. So, we would be talking about the plane z = Ax + By. Which is fine, of course, since this second plane is parallel to the original one, the unique vertical translation that contains the origin. The orthogonal vector we wish to compute is invariant under translations like this, so no harm done.

Granted, dmckee's phrasing is that his specified "vectors" lie in the plane, not the points, so he's arguably covered. But it strikes me as helpful to explicitly acknowledge the implied translations.

Boy, it's been a while for me on this stuff, too.

Pedantically yours... ;-)

David Weinraub