-
Calculating a Normal
I've done a lot of reading about how to find normals, but I just don't quite get it. My understanding so far is:
To find the normal of triangle ABC.
[a-b]x[b-c]
I'm not sure how you subtract vectors.
I'm don't understand how to find a cross product, mostly just because of the math symbols used.
I just need someone to clarify these things for me.
Thanks
-
So cross product, given triange a (x1, y1, z1) b (x2, y2, z2) c (x3, y3, z3), you take any two vectors, the edges, which compose it
Either
ab and bc
ac and ab
ca and cb
And take the cross product
So, a, b, and c represent points in space (must be space, or in 2d, z is some constant)
Cross product of ab and bc for example is ab x bc
ab = <x2 - x1, y2 - y1, z2 - z1>
bc = <x2 - x3, y2 - y3, z2 - z3>
ab x bc = <(y2 - y1)(z2 - z3), (z2 - z1)(y2 - y3), (x2 - x1)(z2 - z3) - (z2 - z1)(x2 - x3), (x2 - x1)(y2 - y3) - (y2 - y1)(x2 - x3)>
This is my vector class implementing such operations
http://pokepong.svn.sourceforge.net/...pp?view=markup
-
And vector subtracting for a = b - c is just
[ ax, ay, az ] = [ bx, by, bz ] - [ cx, cy, cz ] with component-wise subtraction, so the result is
[ bx - cx, by - cy, bz - cz ]
-
Aw, it seems so simple now! Thanks guys :)
edit:
wait..
ab x bc = <(y2 - y1)(z2 - z3), (z2 - z1)(y2 - y3), (x2 - x1)(z2 - z3) - (z2 - z1)(x2 - x3), (x2 - x1)(y2 - y3) - (y2 - y1)(x2 - x3)>
was that subtraction I bolded a mistake?
-
I couldn't see what you posted but I missed a subtraction sign in the first vector components
ab x bc = <(y2 - y1)(z2 - z3) - (z2 - z1)(y2 - y3), (x2 - x1)(z2 - z3) - (z2 - z1)(x2 - x3), (x2 - x1)(y2 - y3) - (y2 - y1)(x2 - x3)>