SurgSim::Math::TriangleHelper< T, MOpt > Class Template Reference

A helper class for a triangle, used for the following two purposes: More...

`#include <SurgSim/Math/TriangleTriangleContactCalculation-inl.h>`

## Public Member Functions

| TriangleHelper (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &n)
| Constructor using the triangle data to initialize. More...
void | findDeepestPenetrationWithTriangle (const TriangleHelper &triangle, T *penetrationDepth, Vector3 *penetrationPoint0, Vector3 *penetrationPoint1)
| Given a triangle, find the deepest vertex in the swept volume of that triangle. More...

## Private Types

typedef Eigen::Matrix< T, 3, 1, MOpt > | Vector3
typedef boost::container::static_vector< Vector3, CAPACITY > | Vertices

## Private Member Functions

void | getPrismPlane (size_t index, Vector3 *planeNormal, T *planeD) const
| Get the bounding plane of the swept volume of this triangle. More...
void | clipAgainstPlane (const Vector3 &planeN, T planeD)
| Clip the polygon given a plane. More...
void | findDeepestVertexUnderPlane (const Vector3 &planeN, T planeD, T *depth, Vector3 *point) const
| Find the deepest vertex of this polygon under the plane. More...

## Private Attributes

const Vector3 * | m_vertices [3]
| Original vertices of the triangle. More...
const Vector3 & | m_normal
| Normal of the triangle. More...
T | m_planeD
| d from the plane equation (n.x + d = 0) for the plane of this triangle. More...
Vertices | m_clippedVerticesBuffer [2]
| The buffers for the clipped vertices of the triangle. More...
size_t | m_receiverBufferIndex

## Static Private Attributes

static const size_t | CAPACITY = 10

## Detailed Description

### template<class T, int MOpt>
class SurgSim::Math::TriangleHelper< T, MOpt >

A helper class for a triangle, used for the following two purposes:

- Clip against a given plane.
- Find the deepest point given a plane. Created as a triangle and can become 4 or more sided polygon when clipped.
  Note
    The vertices are stored in order, so that the edges of the polygon run between adjacent vertices (and from the last vertex to the first).
  Template Parameters

    T | Accuracy of the calculation.
    MOpt | Eigen Matrix options.

## Member Typedef Documentation

## Vector3

template<class T, int MOpt>

typedef Eigen::Matrix<T, 3, 1, MOpt> SurgSim::Math::TriangleHelper< T, MOpt >::Vector3

private

## Vertices

template<class T, int MOpt>

typedef boost::container::static_vector<Vector3, CAPACITY> SurgSim::Math::TriangleHelper< T, MOpt >::Vertices

private

## Constructor & Destructor Documentation

## TriangleHelper()

template<class T, int MOpt>

SurgSim::Math::TriangleHelper< T, MOpt >::TriangleHelper | ( | const Vector3 & | v0,
|  | const Vector3 & | v1,
|  | const Vector3 & | v2,
|  | const Vector3 & | n
| ) |  |

inline

Constructor using the triangle data to initialize.

Parameters

  v0,v1,v2 | The vertices of the triangle.
  n | The normal of the triangle.

## Member Function Documentation

## clipAgainstPlane()

template<class T, int MOpt>

void SurgSim::Math::TriangleHelper< T, MOpt >::clipAgainstPlane | ( | const Vector3 & | planeN,
|  | T | planeD
| ) |  |

inline private

Clip the polygon given a plane.

Any part of the polygon above this plane is clipped.

Note
  This may alter the number of vertices in this polygon.

Parameters

  planeN | The normal of the clipping plane.
  planeD | The d from plane eqn (nx + d) of the clipping plane.

## findDeepestPenetrationWithTriangle()

template<class T, int MOpt>

void SurgSim::Math::TriangleHelper< T, MOpt >::findDeepestPenetrationWithTriangle | ( | const TriangleHelper< T, MOpt > & | triangle,
|  | T * | penetrationDepth,
|  | Vector3 * | penetrationPoint0,
|  | Vector3 * | penetrationPoint1
| ) |  |

inline

Given a triangle, find the deepest vertex in the swept volume of that triangle.

Parameters

  | triangle | The triangle against which the penetration is checked.
  [out] | penetrationDepth | The depth of the deepest point in this triangle to the triangle sent in.
  [out] | penetrationPoint0 | The penetration point on this triangle.
  [out] | penetrationPoint1 | The penetration point on the triangle sent in.

## findDeepestVertexUnderPlane()

template<class T, int MOpt>

void SurgSim::Math::TriangleHelper< T, MOpt >::findDeepestVertexUnderPlane | ( | const Vector3 & | planeN,
|  | T | planeD,
|  | T * | depth,
|  | Vector3 * | point
| ) |  | const

inline private

Find the deepest vertex of this polygon under the plane.

Note
  Asserts if there are no vertices in the polygon.

Parameters

  | planeN | The normal of the plane.
  | planeD | The distance from origin of the plane.
  [out] | depth | The depth of the deepest point in the polygon from the given plane.
  [out] | point | The deepest point in the polgon from the given plane.

## getPrismPlane()

template<class T, int MOpt>

void SurgSim::Math::TriangleHelper< T, MOpt >::getPrismPlane | ( | size_t | index,
|  | Vector3 * | planeNormal,
|  | T * | planeD
| ) |  | const

inline private

Get the bounding plane of the swept volume of this triangle.

The swept volume of a triangle is an infinitely long prism.

Parameters

  index | There are three prism sides, the index indicates which one is to be calculated.
  planeNormal | The outward facing normal of the prism plane.
  planeD | d from the plane equation (n.x + d = 0) of the prism plane.

## Member Data Documentation

## CAPACITY

template<class T, int MOpt>

const size_t SurgSim::Math::TriangleHelper< T, MOpt >::CAPACITY = 10

static private

## m_clippedVerticesBuffer

template<class T, int MOpt>

Vertices SurgSim::Math::TriangleHelper< T, MOpt >::m_clippedVerticesBuffer[2]

private

The buffers for the clipped vertices of the triangle.

## m_normal

template<class T, int MOpt>

const Vector3& SurgSim::Math::TriangleHelper< T, MOpt >::m_normal

private

Normal of the triangle.

## m_planeD

template<class T, int MOpt>

T SurgSim::Math::TriangleHelper< T, MOpt >::m_planeD

private

d from the plane equation (n.x + d = 0) for the plane of this triangle.

## m_receiverBufferIndex

template<class T, int MOpt>

size_t SurgSim::Math::TriangleHelper< T, MOpt >::m_receiverBufferIndex

private

## m_vertices

template<class T, int MOpt>

const Vector3* SurgSim::Math::TriangleHelper< T, MOpt >::m_vertices[3]

private

Original vertices of the triangle.

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

- SurgSim/Math/TriangleTriangleContactCalculation-inl.h