# Normal Direction Detection

## Recommended Posts

bushman_IL    122
Hello,

I am not too familiar with normals so please bare with me. I have meshes that I am trying to rotate so they will lay flush along a line. To give a litle more background, these lines make up the walls of a room. so I know the center point of a room very easily. However, when I get the normal depending on which end of the wall I use first it is possible the normal could be pointing to the outside of the room instead of the inside.

So the fact that I have this normal of the wall and the center point of the room, can someone give me a little help on an efficient way of deternining if I need to flip my normal or if it is indeed pointing to the inside of the room?

I am not sure what other information might be helpful, so let me know if I am leaving anything major out to help better understand the problem I am facing.

Thank you!!

##### Share on other sites
HelloSkitty    152
I'm not sure if this is efficient, but is it possible to take the equation of the wall/plane, say

x+y+z=3, and given the center point of the room, say (5,5,5), the parallel plane passing through the point is

x+y+z=15

Then, take the parametric equation of the normal line, and find out the respective t-values for where it intersects both planes. Based on a comparison of the two values, either increasing or decreasing, it will tell you which direction the normal is facing.

##### Share on other sites
Assuming your mesh is convex (otherwise things are not so simple) then just evaluate dot product between your normal, and (centre of room - any point on the wall) and if the dot product is positive, the normal points towards the centre of the room, otherwise flip it.