And position generatepolygonnormal cpolygon cvector edge
In this example we used two unit vectors as input and the vector returned is also a unit vector. The cross product does not require that the input vectors be unit vectors. If the two input vectors are not unit length then the resulting vector will also not be unit length but it will still be perpendicular. If you require a unit length vector then you will need to normalize the resulting vector.
CVector C;
C.x = (A.y*B.z) – (A.z*B.y);
} 

One very useful application of the cross product is generating what is known as a surface normal. A normalis a unit length vector that describes the direction a polygon is facing.
In Fig 1.30 we see a triangular polygon consisting of three vectors (v1, v2, v3). If we were to subtract v0 from v1 the result would be a vector which describes Edge 1. If we do the same again, this time subtracting v0 from v2 we get Edge 3. The cross product of these two edges yields a vector which, after normalization, is the polygon normal:
www.gameinstitute.com Graphics Programming with DX9  Page 45 of 97 

The following code snippet assumes that the polygon structure has already been initialized with the vertex data and uses some of our previously created vector functions to accomplish this task. This code can also safely cast our polygon vertex structure to a CVector because at this point our vertex structure simply contains an x, y and z position.
CVector GeneratePolygonNormal( CPolygon P ) {
CVector Edge1, Edge2, Normal;
} 



The • symbol is commonly used to express the dot product (inner product) operation between two 

Page 46 of 97 
