THIS DOCUMENT HAS BEEN CERTIFIED
MEANNESS RATING 7/10
 
 
 

    NOTE : vectors are represented by capitals, scalars are represented by lower case. The x, y, and z components of a vector are denoted by '.x', '.y', and '.z' respectively. For example, the x component of the vector V would be represented by 'V.x'.
 
 

    Here is the theory behind calculating useful information using the vertices of a triangle in 3d space. Below is an example of a typical triangle.

 

The vectors A, B, and C are the vertices of the triangle.

The Surface Normal and the Cross Product

    Here is a description of how you calculate the surface normal of the above triangle. (and any other triangle in 3d space)

    A function known as the Cross Product (aka the Vectorial Product) will take an input of two vectors, and generate a vector which is perpendicular to the plane (the normal)on which the two input vectors lie. To get the two input vectors, we used the vectors that represent the edges of the triangle, in the above diagram, these are vectors U and V. U and V are calculated by subtracting A from B and C respectively. Below is a formula for the cross product, in which the vector N is calculated using the vectors U and V.

    The normal must now be normalized. (making sure the vector has a length of one) In the equation below, the length of the vector whose components are represented by 'x', 'y', and 'z'
is calculated and put in 'l'. The components are then divided by 'l'.

 
 

'd' - the distance, and the Dot Product
    The next part of the plane equation is 'd'. This is the distance from the origin to the point on the plane which is nearest to the origin. This is calculated using a function called the Dot Product. (aka the Scalar Product) The dot product take two vectors as an input, and results in a scalar. The dot product has more than one use. It will calculate the 'distance' from the plane to the origin (what we are calculating now) if given the planes normal, and a point on the plane. (This is used in raytracing) If the two vectors given to it are normalized, it will result on the cosine of the angle between the two vectors. Anyway, the previous use (calculating a planes 'distance' from the origin) is what we will be doing now. We have calculated the normal (it must be normalized), and we need a point on the plane. For the point on the plane, we use one of the vertices of the triangle. Vertex A is used in the formula below, in which 'd' is calculated, using the dot product.


 

The Plane Equation
    Below is the plane equation :

    Where x, y, and z are points in 3d space, A, B, and C are the x, y, and z components of the surface normal, and d is the distance value. A point whose components are put into x, y, and z is on the plane if the above equality is satisfied.
 

Polygons
    The above can be applied to polygons with more than 3 vertices as long as all of the vertices are coplanar. For U and V just use two edges of the polygon.
 

Other Uses for Planes
    Another common use for a plane is to check which side of the plane a point is on. To do this calculate the dot product of the surface normal and the point. Check this against d. If it is greater than d, the point is on one side, if it is smaller, the point is on the other. You may want a point on a particular side to have a particulr result, ie you may want your point to generate a result greater than d. If it does not, you may want to reverse the plane. You do this by multiplying the x, y, and z components of the normal and d by -1. This will reverse the sides of the plane.
 

 

      Email suggestions, comments, death threats, questions, etc to :

                mrmeanie@easynet.co.uk
 
 
 

 Return to 3D Algorithms Page