# 2.63a Face Normal Direction Question

I am designing a script and I need to know how to tell if a Face Normal is pointed toward or away from a given vertex.

How do I find this out? My algorithm can not work without knowing the direction of the Normal relative to the given point.

You could simply create a plane from topview in the XY-plane and check the normals direction.
Or you could simply turn on the normals display in the viewport properties.

But it’s a rather safe bet that the normals point outwards, or in other terms, away from the surface. Well, I am not creating anything and I need to know the direction “in code”. I know that a Normal Vector is perpendicular to a plane and that it has two directions, a positive one and a negative one. The positive direction is the default “away” from face direction and the negative direction would be pointed toward the face.

What I need to know is how to tell Python to check out a mesh, not necessarily made by me (it could be any imported mesh as well.), take a face and tell me what direction the normal is facing, away or towards, a given vertex place in scene by my script.

A good example would be the default cube and my script would place a vertex say at (1.5, 0.0, 0.0). Now the script will take a face and the first thing it needs to know is which way that normal is facing because IF the normal faces “away” from our given vertex, the algorithm will subtract inside an equation I set up and IF the normal points “towards” the given vertex, the algorithm sums a certain part of the equation.

After many long hours of trying to perform this job WITHOUT knowing the normal direction, I have found that it is impossible to do what I am doing without that bit of information. Plus, if the person who made the mesh, me or anyone else, accidentally left some normals out of whack, it will destroy the results of the calculation, so I really really really need to know how to figure out which way a normal of a face is pointing.

I know Blender has to recalculate the normal when it needs it, but in the 3D View you can see the direction the normal faces if you have that function turned on, so Blender does know. I tried checking out the Blender code, but I can’t seem to find anything. If Blender can figure out where the normal is in order to flip them all outside or inside, there must be a way for Python to figure it out.

The indices of the vertices of a face are ordered. Using this order you should be able to create two vectors. Taking the cross product of the two vectors should give the normal to the face. If you are creating the face the order of the vertex indices will determine the direction of the normal.

I wrote a script that selects only front facing geometry and then draws an svg from the edges that are connected to those faces.

pay attention to the ‘select front facing’ function