Physsim::Triangle Class Reference

Defines a triangle for use in collision detection and visualization geometries. More...

#include <Triangle.h>

Inheritance diagram for Physsim::Triangle:

Physsim::Base List of all members.

Public Member Functions

 Triangle (Vector3ConstPtr a, Vector3ConstPtr b, Vector3ConstPtr c)
 Constructs the triangle.
 Triangle (const Vector3 &a, const Vector3 &b, const Vector3 &c)
 Constructs the triangle, making copies of the vertices.
 ~Triangle ()
 Destroys the triangle.
 Triangle (const Triangle &t)
void operator= (const Triangle &t)
 Overloads the assignment operator.
Vector3ConstPtr get_vertex (unsigned i) const
 Gets the specified vertex of the triangle.
const Vector3normal () const
bool on_vertex (const Vector3 &x) const
 Determines whether a point is on a vertex of the triangle.
bool on_edge (const Vector3 &x) const
 Determines whether a point is on an edge of the triangle.
bool inside (const Vector3 &x) const
 Determines whether a point is inside this triangle.
bool strictly_inside (const Vector3 &x) const
 Determines whether a point is strictly inside this triangle.
void to_VRML (std::ostream &o, bool wireframe) const
 Sends the triangle to the specified stream using VRML.
void set_a (Vector3ConstPtr a)
 Sets the vertex 'a'.
void set_b (Vector3ConstPtr b)
 Sets the vertex 'b'.
void set_c (Vector3ConstPtr c)
 Sets the vertex 'c'.
void set_a (const Vector3 &a)
void set_b (const Vector3 &b)
void set_c (const Vector3 &c)
Real get_area () const
void force_normal_update ()
 Calculates the outward facing normal for this triangle (triangle is assumed to be oriented counter-clockwise).
Real calc_distance (const Vector3 &point, Vector3 &closest_point) const
 Determines the distance between this triangle and a given point.
Real get_d () const
 Gets the value 'd' in the equation n[X]*x + n[Y]*y + n[Z]*z - d, where n is the normal of the triangle, and [x y z] is a point on the triangle.
Vector3ConstPtr a () const
 The first vertex of the triangle.
Vector3ConstPtr b () const
 The second vertex of the triangle.
Vector3ConstPtr c () const
 The third vertex of the triangle.

Static Public Member Functions

static bool intersects (const Triangle &t1, const Triangle &t2)
 Triangle intersection test, adapted from PQP.
static Triangle transform (const Triangle &t, const Matrix4 &m)
 Transforms the given triangle using the specified transformation matrix.

Detailed Description

Defines a triangle for use in collision detection and visualization geometries.


Member Function Documentation

bool Triangle::intersects ( const Triangle t1,
const Triangle t2 
) [static]

Triangle intersection test, adapted from PQP.

Note:
this method does not work correctly at the moment; see results of test_tri_isect

Vector3ConstPtr Triangle::get_vertex ( unsigned  i  )  const

Gets the specified vertex of the triangle.

Parameters:
i a zero-index in the range [0,2]

void Triangle::force_normal_update (  ) 

Calculates the outward facing normal for this triangle (triangle is assumed to be oriented counter-clockwise).

The user will only need to call this method directly if the triangle's vertices are modified outside of the Triangle class.

Note:
this method computes the 'd' value (the value 'd' in the equation x*n[X] + y*n[Y] + z*n[Z] - d = 0, where [x,y,z] is a point on the plane containing the triangle and n is the triangle's normal) as well.

Real Triangle::calc_distance ( const Vector3 point,
Vector3 closest_point 
) const

Determines the distance between this triangle and a given point.

Parameters:
point the query point
closest_point the closest point on the triangle is returned here
Returns:
the Euclidean distance between this triangle and the point
Note:
I took this code almost verbatim from Dave Eberly; need to ask his permission to use it!


The documentation for this class was generated from the following files:
Generated on Wed Oct 24 14:54:23 2007 for Physsim by  doxygen 1.5.1