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

Class used to find the intersection between a triangle and a capsule. More...

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

## Public Member Functions

| TriangleCapsuleContactCalculation (const Vector3 &tv0, const Vector3 &tv1, const Vector3 &tv2, const Vector3 &tn, const Vector3 &cv0, const Vector3 &cv1, double cr)
| Constructor. More...
bool | isIntersecting ()
void | calculateContact (T *penetrationDepth, Vector3 *penetrationPointTriangle, Vector3 *penetrationPointCapsule, Vector3 *contactNormal, Vector3 *penetrationPointCapsuleAxis)
| Calculate the contact info. More...

## Private Types

typedef Eigen::Matrix< T, 3, 1, MOpt > | Vector3
typedef Eigen::Matrix< T, 2, 1, MOpt > | Vector2
typedef Eigen::Transform< T, 3, Eigen::Isometry > | RigidTransform3

## Private Member Functions

bool | axisAwayFromTriangle ()
| This function handles the contact data calculation for the case where there is an intersection between the capsule and the triangle, but the capsule axis does not intersect the triangle. More...
bool | axisPerpendicularToTriangle ()
| This function handles the contact data calculation for the case where there is an intersection between the capsule and the triangle, and the capsule axis is perpendicular to the triangle. More...
bool | axisTouchingTriangle ()
| This function handles the contact data calculation for the case where there is an intersection between the capsule and the triangle, and the capsule axis just touches the triangle. More...
bool | axisThroughTriangle ()
| This function handles the contact data calculation for the case where there is an intersection between the capsule and the triangle, and the capsule axis goes through the triangle. More...
double | farthestIntersectionLineCylinder (const Vector3 &lineStart, const Vector3 &lineDir, Vector3 *point=nullptr)
double | farthestIntersectionLineCapsule (const Vector3 &lineStart, const Vector &lineDir, Vector3 *point, Vector3 *pointOnCapsuleAxis)
size_t | clipSegmentAgainstTriangle (Vector3 *segmentStart, Vector3 *segmentEnd, Vector3 *v, Vector3 *planeN, double *planeD)

## Private Attributes

double | m_distance
| Distance between triangle and capsule. More...
RigidTransform3 | m_cTransform
| The transform of the capsule. More...
SurgSim::DataStructures::OptionalValue< RigidTransform3 > | m_cInverseTransform
| The inverse transform of the capsule. More...
T | m_epsilon
| epsilon More...
Vector3 | m_tv0
Vector3 | m_tv1
Vector3 | m_tv2
Vector3 | m_tn
Vector3 | m_cvTop
| Capsule ends, axis , radius and length. More...
Vector3 | m_cvBottom
| Capsule ends, axis , radius and length. More...
Vector3 | m_cAxis
| Capsule ends, axis , radius and length. More...
double | m_cr
| Capsule ends, axis , radius and length. More...
double | m_cLength
| Capsule ends, axis , radius and length. More...
T | m_penetrationDepth
Vector3 | m_penetrationPointTriangle
Vector3 | m_penetrationPointCapsule
Vector3 | m_contactNormal
Vector3 | m_penetrationPointCapsuleAxis

## Detailed Description

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

Class used to find the intersection between a triangle and a capsule.

Template Parameters

  T | Accuracy of the calculation, can usually be inferred.
  MOpt | Eigen Matrix options, can usually be inferred.

## Member Typedef Documentation

## RigidTransform3

template<class T, int MOpt>

typedef Eigen::Transform<T, 3, Eigen::Isometry> SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::RigidTransform3

private

## Vector2

template<class T, int MOpt>

typedef Eigen::Matrix<T, 2, 1, MOpt> SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::Vector2

private

## Vector3

template<class T, int MOpt>

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

private

## Constructor & Destructor Documentation

## TriangleCapsuleContactCalculation()

template<class T, int MOpt>

SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::TriangleCapsuleContactCalculation | ( | const Vector3 & | tv0,
|  | const Vector3 & | tv1,
|  | const Vector3 & | tv2,
|  | const Vector3 & | tn,
|  | const Vector3 & | cv0,
|  | const Vector3 & | cv1,
|  | double | cr
| ) |  |

inline

Constructor.

Parameters

  tv0,tv1,tv2 | Vertices of the triangle.
  tn | Normal of the triangle, should be normalized.
  cv0,cv1 | Ends of the capsule axis.
  cr | Capsule radius.

## Member Function Documentation

## axisAwayFromTriangle()

template<class T, int MOpt>

bool SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::axisAwayFromTriangle | ( |  | ) |

inline private

This function handles the contact data calculation for the case where there is an intersection between the capsule and the triangle, but the capsule axis does not intersect the triangle.

Returns
  True, if the axis of the capsule is away from the triangle.

Note
  This function presupposes that isIntersecting() returned true.

## axisPerpendicularToTriangle()

template<class T, int MOpt>

bool SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::axisPerpendicularToTriangle | ( |  | ) |

inline private

This function handles the contact data calculation for the case where there is an intersection between the capsule and the triangle, and the capsule axis is perpendicular to the triangle.

Returns
  True, if the axis of the capsule is perpendicular to the triangle.

Note
  This function presupposes that isIntersecting() returned true and axisAwayFromTriangle() returned false.

## axisThroughTriangle()

template<class T, int MOpt>

bool SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::axisThroughTriangle | ( |  | ) |

inline private

This function handles the contact data calculation for the case where there is an intersection between the capsule and the triangle, and the capsule axis goes through the triangle.

Returns
  True, if the axis of the capsule goes through the triangle. Also calculates the contact info.

Note
  This function presupposes that isIntersecting() returned true, axisAwayFromTriangle() returned false, axisPerpendicularToTriangle() returned false, and axisTouchingTriangle() returned false.

## axisTouchingTriangle()

template<class T, int MOpt>

bool SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::axisTouchingTriangle | ( |  | ) |

inline private

This function handles the contact data calculation for the case where there is an intersection between the capsule and the triangle, and the capsule axis just touches the triangle.

Returns
  True, if the axis of the capsule is just touching triangle.

Note
  This function presupposes that isIntersecting() returned true, axisAwayFromTriangle() returned false, and axisPerpendicularToTriangle() returned false.

## calculateContact()

template<class T, int MOpt>

void SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::calculateContact | ( | T * | penetrationDepth,
|  | Vector3 * | penetrationPointTriangle,
|  | Vector3 * | penetrationPointCapsule,
|  | Vector3 * | contactNormal,
|  | Vector3 * | penetrationPointCapsuleAxis
| ) |  |

inline

Calculate the contact info.

Parameters

  [out] | penetrationDepth | The depth of penetration.
  [out] | penetrationPointTriangle | The contact point on triangle.
  [out] | penetrationPointCapsule | The contact point on capsule.
  [out] | contactNormal | The contact normal that points from capsule to triangle.
  [out] | penetrationPointCapsuleAxis | The point on the capsule axis closest to the triangle.

## clipSegmentAgainstTriangle()

template<class T, int MOpt>

size_t SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::clipSegmentAgainstTriangle | ( | Vector3 * | segmentStart,
|  | Vector3 * | segmentEnd,
|  | Vector3 * | v,
|  | Vector3 * | planeN,
|  | double * | planeD
| ) |  |

inline private

Parameters

  segmentStart | [in,out] The start of the line segment
  segmentEnd | [in,out] The end of the line segment
  v | The vertices of the triangle.
  planeN | Normals of the triangle and each of the edge planes.
  planeD | d from plane equation for the plane of the triangle and each of the edge planes.

Returns
  The index of the last plane which clips the segment passed in.

## farthestIntersectionLineCapsule()

template<class T, int MOpt>

double SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::farthestIntersectionLineCapsule | ( | const Vector3 & | lineStart,
|  | const Vector & | lineDir,
|  | Vector3 * | point,
|  | Vector3 * | pointOnCapsuleAxis
| ) |  |

inline private

Parameters

  lineStart | The start of the line segment
  lineDir | The direction of the line segment
  point | [in,out] The point which is to be clipped.
  pointOnCapsuleAxis | [out] The recalculated point on the capsule axis.

Returns
  The distance of the point of intersection from the lineStart.

Note
  Asserts when there is no intersection.

## farthestIntersectionLineCylinder()

template<class T, int MOpt>

double SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::farthestIntersectionLineCylinder | ( | const Vector3 & | lineStart,
|  | const Vector3 & | lineDir,
|  | Vector3 * | point = `nullptr`
| ) |  |

inline private

Parameters

  lineStart | The origin of the line
  lineDir | Unit directional vector of the line
  point | [out] The point of intersection.

Returns
  The distance of the point of intersection from the lineStart.

## isIntersecting()

template<class T, int MOpt>

bool SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::isIntersecting | ( |  | ) |

inline

Returns
  Whether there is an intersection.

## Member Data Documentation

## m_cAxis

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_cAxis

private

Capsule ends, axis , radius and length.

## m_cInverseTransform

template<class T, int MOpt>

SurgSim::DataStructures::OptionalValue<RigidTransform3> SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_cInverseTransform

private

The inverse transform of the capsule.

## m_cLength

template<class T, int MOpt>

double SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_cLength

private

Capsule ends, axis , radius and length.

## m_contactNormal

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_contactNormal

private

Contact info

## m_cr

template<class T, int MOpt>

double SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_cr

private

Capsule ends, axis , radius and length.

## m_cTransform

template<class T, int MOpt>

RigidTransform3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_cTransform

private

The transform of the capsule.

## m_cvBottom

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_cvBottom

private

Capsule ends, axis , radius and length.

## m_cvTop

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_cvTop

private

Capsule ends, axis , radius and length.

## m_distance

template<class T, int MOpt>

double SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_distance

private

Distance between triangle and capsule.

## m_epsilon

template<class T, int MOpt>

T SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_epsilon

private

epsilon

## m_penetrationDepth

template<class T, int MOpt>

T SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_penetrationDepth

private

Contact info

## m_penetrationPointCapsule

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_penetrationPointCapsule

private

Contact info

## m_penetrationPointCapsuleAxis

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_penetrationPointCapsuleAxis

private

Contact info

## m_penetrationPointTriangle

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_penetrationPointTriangle

private

Contact info

## m_tn

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_tn

private

Triangle vertices and normal.

## m_tv0

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_tv0

private

Triangle vertices and normal.

## m_tv1

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_tv1

private

Triangle vertices and normal.

## m_tv2

template<class T, int MOpt>

Vector3 SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::m_tv2

private

Triangle vertices and normal.

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

- SurgSim/Math/TriangleCapsuleContactCalculation-inl.h