# Normals from Cross

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

## Recommended Posts

Hi guys, I'm parsing Lightwave 3D .obj files where the models are made up of triangles. Then I create the normals using the cross product. Is there a way I can check the normal to make sure it's facing outward, so if it isn't I can just reverse it ? Also, can I tell if going from vertex_01 to vertex_02 is clockwise or counter-clockwise ? Thank you.

##### Share on other sites
If it is a closed mesh you could cast a ray from the surface of the triangle in the direction of the normal. If the number of intersections between the mesh and the ray is even then the normal is pointing outward, if it is odd the normal is pointing inward.

As for the clockwise counter clockwise you will need the third point as well in order to determine clockwise counter clockwise. I think that you could determine CW and CCW like this.

((vertex_03 - vertex_01) x (vertex_02 - vertex_01)) dot normal > 0

So essentially if you need to flip the normal to face outward the triangle's CW or CCW direction is opposite of a triangle where the normal does not need to be flipped. I hope I was helpful.

##### Share on other sites
Thanks Happy.

I found this for testing the orientation of a triangle:

http://www.gamedev.net/reference/articles/article425.asp

I don't understand what the difference is between the orientation() and determinant() functions (except how the parameters are passed.) Neither of them use z-values so maybe they are just for 2D ?

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633289
• Total Posts
3011231
• ### Who's Online (See full list)

There are no registered users currently online

×