Irrlicht Engine: irr::core::triangle3d< T > Class Template Reference

Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# irr::core::triangle3d< T > Class Template Reference

3d triangle template class for doing collision detection and other things. More...

`#include <triangle3d.h>`

List of all members.

## Public Member Functions
core::vector3d< T > | closestPointOnTriangle (const core::vector3d< T > &p) const
| Get the closest point on a triangle to a point on the same plane.
T | getArea () const
| Get the area of the triangle.
bool | getIntersectionOfPlaneWithLine (const vector3d< T > &linePoint, const vector3d< T > &lineVect, vector3d< T > &outIntersection) const
| Calculates the intersection between a 3d line and the plane the triangle is on.
bool | getIntersectionWithLimitedLine (const line3d< T > &line, vector3d< T > &outIntersection) const
| Get an intersection with a 3d line.
bool | getIntersectionWithLine (const vector3d< T > &linePoint, const vector3d< T > &lineVect, vector3d< T > &outIntersection) const
| Get an intersection with a 3d line.
vector3d< T > | getNormal () const
| Get the normal of the triangle.
plane3d< T > | getPlane () const
| Get the plane of this triangle.
bool | isFrontFacing (const vector3d< T > &lookDirection) const
| Test if the triangle would be front or backfacing from any point.
bool | isPointInside (const vector3d< T > &p) const
| Check if a point is inside the triangle.
bool | isPointInsideFast (const vector3d< T > &p) const
| Check if a point is inside the triangle.
bool | isTotalInsideBox (const aabbox3d< T > &box) const
| Determines if the triangle is totally inside a bounding box.
bool | isTotalOutsideBox (const aabbox3d< T > &box) const
| Determines if the triangle is totally outside a bounding box.
bool | operator!= (const triangle3d< T > &other) const
| Inequality operator.
bool | operator== (const triangle3d< T > &other) const
| Equality operator.
void | set (const core::vector3d< T > &a, const core::vector3d< T > &b, const core::vector3d< T > &c)
| sets the triangle's points
| triangle3d (vector3d< T > v1, vector3d< T > v2, vector3d< T > v3)
| Constructor for triangle with given three vertices.
| triangle3d ()
| Constructor for an all 0 triangle.
## Public Attributes
vector3d< T > | pointA
| the three points of the triangle
vector3d< T > | pointB
vector3d< T > | pointC

## Detailed Description

### template<class T>
class irr::core::triangle3d< T >

3d triangle template class for doing collision detection and other things.

Definition at line 20 of file triangle3d.h.

## Constructor & Destructor Documentation

template<class T>

irr::core::triangle3d< T >::triangle3d | ( |  | ) | `[inline]`

Constructor for an all 0 triangle.

Definition at line 25 of file triangle3d.h.

template<class T>

irr::core::triangle3d< T >::triangle3d | ( | vector3d< T > | v1,
|  | vector3d< T > | v2,
|  | vector3d< T > | v3 |
| ) |  |  | `[inline]`

Constructor for triangle with given three vertices.

Definition at line 27 of file triangle3d.h.

## Member Function Documentation

template<class T>

core::vector3d<T> irr::core::triangle3d< T >::closestPointOnTriangle | ( | const core::vector3d< T > & | p | ) | const`[inline]`

Get the closest point on a triangle to a point on the same plane.

Parameters:

  | p | Point which must be on the same plane as the triangle.

Returns:
  The closest point of the triangle

Definition at line 68 of file triangle3d.h.

References irr::core::vector3d< T >::getDistanceFrom(), irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

template<class T>

T irr::core::triangle3d< T >::getArea | ( |  | ) | const`[inline]`

Get the area of the triangle.

Definition at line 205 of file triangle3d.h.

References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

template<class T>

bool irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine | ( | const vector3d< T > & | linePoint,
|  | const vector3d< T > & | lineVect,
|  | vector3d< T > & | outIntersection |
| ) |  |  | const`[inline]`

Calculates the intersection between a 3d line and the plane the triangle is on.

Parameters:

  | lineVect | Vector of the line to intersect with.
  | linePoint | Point of the line to intersect with.
  | outIntersection | Place to store the intersection point, if there is one.

Returns:
  True if there was an intersection, else false.

Definition at line 162 of file triangle3d.h.

References irr::core::vector3d< T >::dotProduct(), irr::core::triangle3d< T >::getNormal(), irr::core::iszero(), and irr::core::triangle3d< T >::pointA.

Referenced by irr::core::triangle3d< T >::getIntersectionWithLine().

template<class T>

bool irr::core::triangle3d< T >::getIntersectionWithLimitedLine | ( | const line3d< T > & | line,
|  | vector3d< T > & | outIntersection |
| ) |  |  | const`[inline]`

Get an intersection with a 3d line.

Parameters:

  | line | Line to intersect with.
  | outIntersection | Place to store the intersection point, if there is one.

Returns:
  True if there was an intersection, false if not.

Definition at line 129 of file triangle3d.h.

References irr::core::line3d< T >::end, irr::core::triangle3d< T >::getIntersectionWithLine(), irr::core::line3d< T >::getVector(), irr::core::vector3d< T >::isBetweenPoints(), and irr::core::line3d< T >::start.

template<class T>

bool irr::core::triangle3d< T >::getIntersectionWithLine | ( | const vector3d< T > & | linePoint,
|  | const vector3d< T > & | lineVect,
|  | vector3d< T > & | outIntersection |
| ) |  |  | const`[inline]`

Get an intersection with a 3d line.

Please note that also points are returned as intersection which are on the line, but not between the start and end point of the line. If you want the returned point be between start and end use getIntersectionWithLimitedLine().

Parameters:

  | linePoint | Point of the line to intersect with.
  | lineVect | Vector of the line to intersect with.
  | outIntersection | Place to store the intersection point, if there is one.

Returns:
  True if there was an intersection, false if there was not.

Definition at line 147 of file triangle3d.h.

References irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine(), and irr::core::triangle3d< T >::isPointInside().

Referenced by irr::core::triangle3d< T >::getIntersectionWithLimitedLine().

template<class T>

vector3d<T> irr::core::triangle3d< T >::getNormal | ( |  | ) | const`[inline]`

Get the normal of the triangle.

Please note: The normal is not always normalized.

Definition at line 180 of file triangle3d.h.

References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

Referenced by irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine(), and irr::core::triangle3d< T >::isFrontFacing().

template<class T>

plane3d<T> irr::core::triangle3d< T >::getPlane | ( |  | ) | const`[inline]`

Get the plane of this triangle.

Definition at line 199 of file triangle3d.h.

References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

template<class T>

bool irr::core::triangle3d< T >::isFrontFacing | ( | const vector3d< T > & | lookDirection | ) | const`[inline]`

Test if the triangle would be front or backfacing from any point.

Thus, this method assumes a camera position from which the triangle is definitely visible when looking at the given direction. Do not use this method with points as it will give wrong results!

Parameters:

  | lookDirection | Look direction.

Returns:
  True if the plane is front facing and false if it is backfacing.

Definition at line 191 of file triangle3d.h.

References irr::core::vector3d< T >::dotProduct(), F32_LOWER_EQUAL_0, and irr::core::triangle3d< T >::getNormal().

template<class T>

bool irr::core::triangle3d< T >::isPointInside | ( | const vector3d< T > & | p | ) | const`[inline]`

Check if a point is inside the triangle.

Parameters:

  | p | Point to test. Assumes that this point is already on the plane of the triangle.

Returns:
  True if the point is inside the triangle, otherwise false.

Definition at line 88 of file triangle3d.h.

References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

Referenced by irr::core::triangle3d< T >::getIntersectionWithLine().

template<class T>

bool irr::core::triangle3d< T >::isPointInsideFast | ( | const vector3d< T > & | p | ) | const`[inline]`

Check if a point is inside the triangle.

This method is an implementation of the example used in a paper by Kasper Fauerby original written by Keidy from Mr-Gamemaker.

Parameters:

  | p | Point to test. Assumes that this point is already on the plane of the triangle.

Returns:
  True if point is inside the triangle, otherwise false.

Definition at line 102 of file triangle3d.h.

References irr::core::vector3d< T >::dotProduct(), irr::core::IR(), irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

template<class T>

bool irr::core::triangle3d< T >::isTotalInsideBox | ( | const aabbox3d< T > & | box | ) | const`[inline]`

Determines if the triangle is totally inside a bounding box.

Parameters:

  | box | Box to check.

Returns:
  True if triangle is within the box, otherwise false.

Definition at line 44 of file triangle3d.h.

References irr::core::aabbox3d< T >::isPointInside(), irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

template<class T>

bool irr::core::triangle3d< T >::isTotalOutsideBox | ( | const aabbox3d< T > & | box | ) | const`[inline]`

Determines if the triangle is totally outside a bounding box.

Parameters:

  | box | Box to check.

Returns:
  True if triangle is outside the box, otherwise false.

Definition at line 54 of file triangle3d.h.

References irr::core::aabbox3d< T >::MaxEdge, irr::core::aabbox3d< T >::MinEdge, irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

template<class T>

bool irr::core::triangle3d< T >::operator!= | ( | const triangle3d< T > & | other | ) | const`[inline]`

Inequality operator.

Definition at line 36 of file triangle3d.h.

template<class T>

bool irr::core::triangle3d< T >::operator== | ( | const triangle3d< T > & | other | ) | const`[inline]`

Equality operator.

Definition at line 30 of file triangle3d.h.

References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

template<class T>

void irr::core::triangle3d< T >::set | ( | const core::vector3d< T > & | a,
|  | const core::vector3d< T > & | b,
|  | const core::vector3d< T > & | c |
| ) |  |  | `[inline]`

sets the triangle's points

Definition at line 212 of file triangle3d.h.

References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.

## Member Data Documentation

template<class T>

vector3d<T> irr::core::triangle3d< T >::pointA

the three points of the triangle

Definition at line 220 of file triangle3d.h.

Referenced by irr::core::triangle3d< T >::closestPointOnTriangle(), irr::core::triangle3d< T >::getArea(), irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine(), irr::core::triangle3d< T >::getNormal(), irr::core::triangle3d< T >::getPlane(), irr::core::triangle3d< T >::isPointInside(), irr::core::triangle3d< T >::isPointInsideFast(), irr::core::triangle3d< T >::isTotalInsideBox(), irr::core::triangle3d< T >::isTotalOutsideBox(), irr::core::triangle3d< T >::operator==(), and irr::core::triangle3d< T >::set().

template<class T>

vector3d<T> irr::core::triangle3d< T >::pointB

Definition at line 221 of file triangle3d.h.

Referenced by irr::core::triangle3d< T >::closestPointOnTriangle(), irr::core::triangle3d< T >::getArea(), irr::core::triangle3d< T >::getNormal(), irr::core::triangle3d< T >::getPlane(), irr::core::triangle3d< T >::isPointInside(), irr::core::triangle3d< T >::isPointInsideFast(), irr::core::triangle3d< T >::isTotalInsideBox(), irr::core::triangle3d< T >::isTotalOutsideBox(), irr::core::triangle3d< T >::operator==(), and irr::core::triangle3d< T >::set().

template<class T>

vector3d<T> irr::core::triangle3d< T >::pointC

Definition at line 222 of file triangle3d.h.

Referenced by irr::core::triangle3d< T >::closestPointOnTriangle(), irr::core::triangle3d< T >::getArea(), irr::core::triangle3d< T >::getNormal(), irr::core::triangle3d< T >::getPlane(), irr::core::triangle3d< T >::isPointInside(), irr::core::triangle3d< T >::isPointInsideFast(), irr::core::triangle3d< T >::isTotalInsideBox(), irr::core::triangle3d< T >::isTotalOutsideBox(), irr::core::triangle3d< T >::operator==(), and irr::core::triangle3d< T >::set().

The documentation for this class was generated from the following file:

- triangle3d.h

| The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Sun Oct 24 12:42:03 2010 by Doxygen (1.6.2)