Main Page   Modules   Class Hierarchy   Compound List   Compound Members  

GAUGE3D::GPolygon Class Reference

Represents a polygon with an arbitrary number of sides. More...

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

List of all members.

Public Methods

 GPolygon ()
 Creates a polygon with no sides.

 GPolygon (const GTriangle &triangle)
 Creates a polygon equivalent to the given triangle.

 GPolygon (const GPolygon &other)
 Copy constructor.

 GPolygon (GVector vertices[],int num)
 Creates a polygon with the given vertices.

 ~GPolygon ()
 Destructor.

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

void Resize (int num,bool copy)
 Change the number of vertices. More...

void Split (GTriangle triangles[])const
 Splits the polygon into triangles. More...

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

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

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

int NumVertices ()const
 The number of vertices in the polygon.

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

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

const GPolygon& operator= (const GPolygon other)
 Assignment operator.


Detailed Description

Represents a polygon with an arbitrary number of sides.

I recommend against using this class except when other methods are extremely inconvenient. This class uses dynamic memory, which makes it unsuitable for fast math computations.


Member Function Documentation

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

Gets the plane which the polygon 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 polygon appear clockwise.

void GAUGE3D::GPolygon::Resize ( int num,
bool copy )
 

Change the number of vertices.

Parameters:
num   New number of vertices in the polygon.
copy   True if the old vertices should be copied into the new list.

void GAUGE3D::GPolygon::Split ( GTriangle triangles[] ) const
 

Splits the polygon into triangles.

Parameters:
triangles   An array containing at least the number of vertices minus two triangles. These will be overwritten with the triangles that make up the polygon.

void GAUGE3D::GPolygon::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 polygon faces will be reversed, since that direction is the direction from which the vertices appear in clockwise order.

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

Finds whether or not the line intersects the polygon, 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 polygon, or -1 if the line hits the back of the polygon. (the front side is the side from which the vertices of the polygon 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