# normal values flipped (sometimes) ...

This topic is 2641 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a complex 3D mesh and I'd like to calculate the normal of a point laying in one of the mesh triangles.

So I have a point P which is laying in a triangle with vertices A,B,C (to calculate ABC coordinates I iterate all the mesh vertices and gather the 3 points which are closest to P).

I calculate the normal vector to the triangle like this:

normalVector = (C-A)^(B-A); // ^ is the cross product

The problem is that the resulting vector is sometimes flipped, and I can't understand why. Is the order of of vector subtractions important?
Thanks

##### Share on other sites

The problem is that the resulting vector is sometimes flipped, and I can't understand why. Is the order of of vector subtractions important?
Thanks

Order is important when it comes to a cross product. That is A cross B != B cross A (in fact, A cross B == -(B cross A)). In other words, switching the order of A and B will flip the result of the cross product. Looking at this, you can hopefully see what it is I'm trying to convey. It sounds like, in your case, ABC will be clockwise for some of the triangles, whereas ABC will be counterclockwise for the other triangles.

##### Share on other sites
If you're importing from Blender (I suspect the problem might arise with other DCC tools as well), there might be another thing worth trying before you crack your head open...

Blender by default will try to guess the "out" face for you. It will also render triangles with no backface culling. It is therefore dead simple to have a normal flipped, yet do not recognize it. Normal's direction will then be used to choose the "visible" face when exporting. Perhaps it is worth checking normals are actually born in the expected direction.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633674
• Total Posts
3013276
×