## Facet Normals

A surface normal, is a vector that is perpendicular to that surface. When applied to computer graphics, and in particular when it is applied to meshes composed of polygons, it is often called a facet normal. In other words, consider a mesh composed of triangles. The facet normal is that vector which is perpendicular to each triangle. It is often simplified to normal, for the purposes of abbreviation.

A normal can be calculated as the vector cross product of two edges of the triangle (or polygon), as long as those edges are not parallel.

``` 1. int main(int argc, char **argv)
2. {
3.    Cvector3 *vertex, *face_normal, a, b;
4.    :
5.    :
6. //
7. // Step 1. Loop thru faces; calculate face normals
8. //
9.   for(i=0;i<number_of_triangles;i++) {
10.     index1 = face[3*i+0];
11.     index2 = face[3*i+1];
12.     index3 = face[3*i+2];
13.     a = vertex[index2] - vertex[index3];
14.     b = vertex[index1] - vertex[index3];
15.     face_normal.Cross(a,b);
16.   }
17.   :
18.   :
19.   return 0;
20. }
```

Back to Types of Normal Vectors