Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

gmtl::Tri Class Template Reference
[Abstract Data Types: Matrix, Vec, Quat, Coord, Sphere, Plane]

This class defines a triangle as a set of 3 points order in CCW fashion. More...

#include <Tri.h>

Collaboration diagram for gmtl::Tri:

Collaboration graph
[legend]
List of all members.

Public Methods

 Tri ()
 Constructs a new triangle with all vertices at the origin. More...

 Tri (const Point< DATA_TYPE, 3 > &p1, const Point< DATA_TYPE, 3 > &p2, const Point< DATA_TYPE, 3 > &p3)
 Constructs a new triangle with the given points. More...

 Tri (const Tri< DATA_TYPE > &tri)
 Constructs a duplicate of the given triangle. More...

Vec< DATA_TYPE, 3 > edge (int idx) const
 Gets the nth edge of the triangle where edge0 corresponds to the vector from vertex 0 to 1, edge1 corresponds to the vector from vertex 1 to 2 and edge2 corresponsds to the vector from vertex 2 to vertex 0. More...

void set (const Point< DATA_TYPE, 3 > &p1, const Point< DATA_TYPE, 3 > &p2, const Point< DATA_TYPE, 3 > &p3)
 Set the triangle with the given points. More...

Point< DATA_TYPE, 3 > & operator[] (int idx)
const Point< DATA_TYPE, 3 > & operator[] (int idx) const

Detailed Description

template<class DATA_TYPE>
class gmtl::Tri< DATA_TYPE >

This class defines a triangle as a set of 3 points order in CCW fashion.

Triangle points are tri(s,t) = b+s*e0+t*e1 where 0 <= s <= 1, 0 <= t <= 1, and 0 <= s+t <= 1.

Definition at line 52 of file Tri.h.


Constructor & Destructor Documentation

template<class DATA_TYPE>
gmtl::Tri< DATA_TYPE >::Tri   [inline]
 

Constructs a new triangle with all vertices at the origin.

Definition at line 58 of file Tri.h.

00058 {}

template<class DATA_TYPE>
gmtl::Tri< DATA_TYPE >::Tri const Point< DATA_TYPE, 3 > &    p1,
const Point< DATA_TYPE, 3 > &    p2,
const Point< DATA_TYPE, 3 > &    p3
[inline]
 

Constructs a new triangle with the given points.

The points must be passed in in CCW order.

Parameters:
p1  vertex0
p2  vertex1
p3  vertex2
Precondition:
p1, p2, p3 must be in CCW order

Definition at line 70 of file Tri.h.

00072    {
00073       mVerts[0] = p1;
00074       mVerts[1] = p2;
00075       mVerts[2] = p3;
00076    }

template<class DATA_TYPE>
gmtl::Tri< DATA_TYPE >::Tri const Tri< DATA_TYPE > &    tri [inline]
 

Constructs a duplicate of the given triangle.

Parameters:
tri  the triangle to copy

Definition at line 83 of file Tri.h.

00084    {
00085       mVerts[0] = tri[0];
00086       mVerts[1] = tri[1];
00087       mVerts[2] = tri[2];
00088    }


Member Function Documentation

template<class DATA_TYPE>
Vec<DATA_TYPE, 3> gmtl::Tri< DATA_TYPE >::edge int    idx const [inline]
 

Gets the nth edge of the triangle where edge0 corresponds to the vector from vertex 0 to 1, edge1 corresponds to the vector from vertex 1 to 2 and edge2 corresponsds to the vector from vertex 2 to vertex 0.

Parameters:
idx  the ordered edge index
Precondition:
0 <= idx <= 2
Returns:
a vector from vertex idx to vertex (idx+1)mod size

Definition at line 121 of file Tri.h.

References gmtlASSERT.

00122    {
00123       gmtlASSERT( (0 <= idx) && (idx <= 2) );
00124       int idx2 = ( idx == 2 ) ? 0 : idx + 1;
00125       return (mVerts[idx2] - mVerts[idx]);
00126    }

template<class DATA_TYPE>
const Point<DATA_TYPE, 3>& gmtl::Tri< DATA_TYPE >::operator[] int    idx const [inline]
 

Parameters:
idx  the index to the vertex in the triangle
Precondition:
0 <= idx <= 2
Returns:
the nth vertex as a point

Definition at line 104 of file Tri.h.

References gmtlASSERT.

00105    {
00106       gmtlASSERT( (0 <= idx) && (idx <= 2) );
00107       return mVerts[idx];
00108    }

template<class DATA_TYPE>
Point<DATA_TYPE, 3>& gmtl::Tri< DATA_TYPE >::operator[] int    idx [inline]
 

Parameters:
idx  the index to the vertex in the triangle
Precondition:
0 <= idx <= 2
Returns:
the nth vertex as a point

Definition at line 99 of file Tri.h.

References gmtlASSERT.

00100    {
00101       gmtlASSERT( (0 <= idx) && (idx <= 2) );
00102       return mVerts[idx];
00103    }

template<class DATA_TYPE>
void gmtl::Tri< DATA_TYPE >::set const Point< DATA_TYPE, 3 > &    p1,
const Point< DATA_TYPE, 3 > &    p2,
const Point< DATA_TYPE, 3 > &    p3
[inline]
 

Set the triangle with the given points.

The points must be passed in in CCW order.

Parameters:
p1  vertex0
p2  vertex1
p3  vertex2
Precondition:
p1, p2, p3 must be in CCW order

Definition at line 138 of file Tri.h.

00140    {
00141       mVerts[0] = p1;
00142       mVerts[1] = p2;
00143       mVerts[2] = p3;
00144    }


The documentation for this class was generated from the following file:
Generated on Mon Apr 7 15:29:32 2003 for GenericMathTemplateLibrary by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002