Archived

This topic is now archived and is closed to further replies.

Kyo

cross product of two vectors non commutative?

Recommended Posts

normal = crossProduct(ab,bc); and normal = crossProduct(bc,ab); doesn''t make any noticeable difference in lighting my rotating pyramid. Is there a difference between the two and how do I know which one will give me a normal facing the right way?

Share this post


Link to post
Share on other sites
As you may know

A Cross B = -(B Cross A)

It doesn''t make a difference in ligthing because ligthing uses the Dot product (and apparently, it uses the absolute value of the dot product in your case). As long as you always use your vertices in the same order for the cross product (ab, bc) or (bc, ab), your normal should point consistently "outside" or "inside" the surface. Try it with a sample triangle, and if your normal doesn''t point in the right direction, switch the order of the vertices.

I hope my explanation isn''t too confusing,

Cédric

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Do the cross product of the two segments counter clockwise with respect to the normal shooting out the face. Also, build the segments counter clockwise too. When you are finished, the normal will be pointing in the direction where the face values are clockwise with respect to the face.

If that makes any sence. Otherwise read up on the subject and do some math.

Share this post


Link to post
Share on other sites