Main Page   Modules   Class Hierarchy   Compound List   Compound Members  

GAUGE3D::GTriangle Class Reference

Represents a triangle in 3-space. More...

#include <gauge3d/3dmath/triangle.h>

List of all members.

Public Methods

 GTriangle ()
 Leaves vertices uninitialized.

 GTriangle (const GVector &vertex1,const GVector &vertex2,const GVector &vertex3)
 Initializes vertices to specified values.

 GTriangle (GVector vertices[])
 Initializes to a three-vertex array.

void GetPlane (GPlane *plane)const
 Gets the plane which the triangle is on. More...

void Reverse ()
 Reverses the direction of the vertices. More...

bool Contains (const GVector &point)
 Returns true if the point is on the triangle.

int8 Intersects (const GLine &line)
 Finds whether or not the line intersects the triangle, and from which side if so. More...

GVectoroperator[] (int index)
 Array access to vertices.

const GVectoroperator[] (int index)const
 Array access to vertices.


Detailed Description

Represents a triangle in 3-space.


Member Function Documentation

void GAUGE3D::GTriangle::GetPlane ( GPlane * plane ) const
 

Gets the plane which the triangle is on.

Parameters:
plane   Points to the location to which to write the plane.
Note:
The plane will face in the direction from which the vertices of the triangle appear clockwise.

void GAUGE3D::GTriangle::Reverse ( )
 

Reverses the direction of the vertices.

Remarks:
This does not reverse the order of the vertices. It just swaps two of the vertices so that clockwise becomes counter-clockwise. This also means that the direction that the triangle faces will be reversed, since that direction is the direction from which the vertices appear in clockwise order.

int8 GAUGE3D::GTriangle::Intersects ( const GLine & line )
 

Finds whether or not the line intersects the triangle, and from which side if so.

Parameters:
line   The line with which to test for intersection.
Returns:
0 if there is no intersection, 1 if the line hits the front of the triangle, or -1 if the line hits the back of the triangle. (the front side is the side from which the vertices of the triangle appear clockwise.)
Remarks:
This function is very fast. It is actually faster than Contains(), so if you want to find the point of intersection, first call this and then call GPlane::FindIntersection if necessary.


The documentation for this class was generated from the following file:
Generated at Tue Jan 30 17:07:34 2001 for gauge3d by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000