] > Lecture: Normal Vectors

Lecture: Normal Vectors

Note: this web page uses MathML, mathematics markup for the web. We have installed mathjax which should render the MathML, But if the maths rendering looks broken, try Firefox, as it has strong MathML support. Chrome/Chromium support is being introduced

Background

A normal vector is a vector perpendicular to a surface, or more mathematically speaking, to a tangent plane.

Normal vectors are used in lighting calculations, and in other rendering effects such as normal and bump mapping. They are also useful for visual debugging.

A flat, i.e. planar polygon only has one normal, which applies to the whole polygon including vertices.

In computer graphics polygon mesh models are often used as approximations of curved surfaces. In that case normals to the actual surface at vertices, i.e. vertex normals are needed, rather than face or polygon normals (see below).

There are situations where polygonal meshes are not approximating curved surfaces, and face normals are appropriate.

Calculating Normals

A normal to a single polygon or face, i.e. a polygon or face normal can be calculated by taking the cross product of two vectors lying in the same plane as the polygon:

Assume a polygon has vertices:

P = ( x0 , y0 , z0 ) , ( x1 , y1 , z1 ) , ( x2 , y2 , z2 ) ,

then vectors A and B can be found as follows

A = < x1 - x0 , y1 - y0 , z1 - z0 > B = < x2 - x0 , y2 - y0 , z2 - z0 >

and the polygon normal found as

N = A × B

Equally, other vertices could have been used for calculating A and B

Face normals can be used to find (approximate) vertex normals by calculating and normalising the average of the (normalised) face normals of the faces which meet at the vertex:

Analytically Defined Surfaces

For analytically defined surfaces which are differentiable normals can be calculated using differentiation and tangent vectors.

1D Curve

For a 1D curve y=f(x) a tangent vector T to a function y=f(x) is simply T = < 1 , dy dx >

The normal vector and the tangent vector are orthogonal, and so N . T = 0 .

From this it can be seen that N = < -dy dx , 1 >

(Note that there is also another possible direction N = < dy dx , -1 > )

2D Surface (3D object)

For analytical 2D surfaces N = < -y x , 1 , -y z >

This equation can be understood as the result of the cross product of two tangent vectors, one in the xy plane and one in the yz plane, both lying in the tangent plane at a point on the surface:

Txy = < 1 , y x , 0 > Tyz = < 0 , y z , 1 > N = Tyz × Txy

The second tangent vector is sometimes called the binormal, and sometimes the bitangent, but strictly speaking it is not. Also these terms have been mixed up at different times, and are used differently in computer graphics to mathematics.

Spheres

In the special case of a sphere the normals are trivially found as a vector from the sphere origin to a point on the surface, and normalised by dividing by the radius.

Model Data

Normals are often supplied as part of model data along with vertex coordinates, face connectivity, colour, textures etc.