Normals are used particularly for 2 things: lighting (OpenGL) and collision detection (math).

A normal is a line (not a visual line, although it can be represented visually) that starts at some point on a polygon, and extends perpendicular to the triangle’s plane. So generally it’s where the polygon is facing.

For instance, if I had a triangle laying flat on Y=0, and it’s facing up, then it’s normal would be 0,1,0.

When it comes to lighting, normals define how a polygon is “lit”. They can be specified either per-face (as described in the example above) or per-vertex. Per-face normals tend to leave the lit geometry with a rough look, where the edges are clearly visible. Per-vertex normals give lit geometry a smooth look.

So with per-face normals, you would define the normal (with glNormal…()) once before you draw each face in the geometry. With per-vertex normals, you would define the normal before each vertex thats drawn in the geometry.

Calculating the face normal for a triangle with vertices A,B,C is pretty easy:

vector3D u,v;

u = B-A;

v = C-A;

vector3D normal;

normal = u.cross(v);

normal.normalize();

vector3D is any object that can represent a value with 3 components (X, Y, and Z). The “.cross” function is crossProduct, and is calculated like this:

…vector3D u …vector3D v

vector3D crossProduct;

crossProduct.x=u.y*v.z-v.y*u.z;

crossProduct.y=u.z*v.x-v.z*u.x;

crossProduct.z=u.x*v.y-v.x*u.y;

The “.normalize” functions make sure that the “length” of the vector is 1. This is how you find out if the length of a vector:

double length = sqrt(vector.x*vector.x+vector.y*vector.y+vector.z*vector.z);

Now for the normalize function, if the length of the vector is greater than zero, then you simply divide each component of the vector by its length.