Converting vertex normals to face normals

geometry, graphics, javascript, normals, visualization

Solution

You can simply determines the orientation of crossed normal by dot it with one of vertex normal or average of all 3 vertices.

Here is the pseudo code:

Vec3 CalcNormalOfFace( Vec3 pPositions[3], Vec3 pNormals[3] )
{
    Vec3 p0 = pPositions[1] - pPositions[0];
    Vec3 p1 = pPositions[2] - pPositions[0];
    Vec3 faceNormal = crossProduct( p0, p1 );

    Vec3 vertexNormal = pNormals[0]; // or you can average 3 normals.
    float dot = dotProduct( faceNormal, vertexNormal );

    return ( dot < 0.0f ) ? -faceNormal : faceNormal;
}

Problem

I have a triangulated polyhedron (not necessarily convex) and the following information: A list of the position of each vertex. A list of the vertex triples that define each face. A list of the vertex normals (Here the vertex normals are vectors from each vertex that are calculated by averaging face normals (see below) around each vertex). I would like to calculate the list of face normals (The normalized vectors perpendicular to the plane of each face, pointing outward).

Original source