Board Thread:Program Announcements/@comment-25017421-20140603081447/@comment-5334617-20140617150516

As for the normal:

If you have three points on a plane, (x1, y1, z1), (x2, y2, z2), (x3, y3, z3), you can create two vectors parallel to the plane: (x2-x1, y2-y1, z2-z1) and (x3-x1, y3-y1, z3-z1). If these vectors are not collinear, the cross product will give a vector perpendicular to both. (If they are collinear, the three points didn't really define a plane, just a line; the cross product will be zero, and you need to pick a different set of three points to define the plane.)  The vector may point 'inward' or 'outward'; if the surfaces are all triangles, and the list of vertices always give the same clockwise-or-anticlockwise sense as viewed from 'outside', and you take the values (x1, y1, z1) etc. in a consistent way from the list, all your calculated vectors will point in the same direction (in or out). The result of the cross product may also be any length; be sure to regularize the length to 1 before doing more calculations.

To estimate the normal at a vertex, calculate normal vectors for all the surfaces that meet at the vertex, take the average of all those, then regularize the length to 1 again.