Previous   |  Next   |  Back to Technical Manual Index

3.5. Module: GlMath

-Class Hierarchy

GlMath is not a subclass of any other class.

-Authorship
Developed by Kwan Skinner

-Description

At a high level, this class contains all the required math functions required to compute the normal of a given triangle.  All these functions are contained within one method named Normal() which takes three GLpoints as arguments.  A GLpoint contains the information necessary to represent a point in three-space.
-Implementation Details
The normal of a triangle is computed from the verticies of a triangle as follows.  First two vectors representing these three points are computed by taking the difference of any two sets of two verticies.  For this method's purposes, v2 - v1 and v3 - v2 are computed, where v1, v2, and v3 are the verticies passed to this method.  Next the cross product of these two vectors are computed to yield a third vector that is orthogonal to the the other two verticies.  Finally this vector is normalized by computing the length of the result of the cross product operation, the cross product vector, and dividing each of the x, y and z coordinates of the cross product vector by this length.  This result is then returned as the result of this method.
-Methods

Normal( GLpoint v1, GLpoint v2, GLpoint v3 )
Description: This method returns a vector that is normal to a triangle.

Inputs: Three GLpoints that represent the three verticies of the triangle who's normal is sought.

Outputs: A vector that is normal to the surface of the triangle specified by the verticies v1, v2 and v3.

Assumptions: None

Exceptions: None

Known Bugs: None

Previous  |  Back to Technical Manual Index