Normalizing triangles (or plains) defined by 3 points?
P, Q, R are points in the triangle (or on the plain)
P (X1, Y1, Z1)
Q (X2, Y2, Z2)
R (X3, Y3, Z3)
V1, V2 are vectors:
V1 = PQ
V2 = PR
V1 = Q - P = (X2 - X1, Y2 - Y1, Z2 - Z1)
V2 = R - P = (X3 - X1, Y3 - Y1, Z3 - Z1)
N is normal (being calculated by cross product):
The result of a corss product of two vector is a vector, perpendicular to the plain. It's calculated like this:
If Q1 and Q2 are two vectors:
Q1 = (X1, Y1, Z1)
Q2 = (X2, Y2, Z2)
Then cross product C is:
C = Q1 x Q2 = (Y1*Z2 - Y2*Z1, Z1*X2 - Z2*X1, X1*Y2 - X2*Y1)
So in the case of vectors V1 and V2:
N = V1 x V2 = ((Y2 - Y1) * (Z3 - Z1) - (Y3 - Y1) * (Z2 - Z1), (Z2 - Z1) * (X3 - X1) - (Z3 - Z1) * (X2 - X1), (X2 - X1) * (Y3 - Y1) - (X3 - X1) * (Y2 - Y1))
Hope this helps. Yea, I know, very confusing with all the long lines, but if you go over it slowly, you'll see that I just added the components of vectors V1 and V2 into equation for cross product... and I got my V1 and V2 vectors by going from point P to point Q and from point P to point R. You have to subtract the second one from the first to get the vector.
-----Posted Added-----
One more thing to watch out for:
If V1 and V2 are two vectors, then
V1 x V2 = - V2 x V1
The thing is... if you do it from the other way, you're gonna end up with a normal facing the other way.