Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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< RigidTransform3m_cInverseTransform
 The inverse transform of the capsule. More...
 
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...
 
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
TAccuracy of the calculation, can usually be inferred.
MOptEigen 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,tv2Vertices of the triangle.
tnNormal of the triangle, should be normalized.
cv0,cv1Ends of the capsule axis.
crCapsule radius.

Member Function Documentation

◆ axisAwayFromTriangle()

template<class T , int MOpt>
bool SurgSim::Math::TriangleCapsuleContactCalculation::TriangleCapsuleContactCalculation< T, MOpt >::axisAwayFromTriangle ( )
inlineprivate

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 ( )
inlineprivate

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 ( )
inlineprivate

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 ( )
inlineprivate

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]penetrationDepthThe depth of penetration.
[out]penetrationPointTriangleThe contact point on triangle.
[out]penetrationPointCapsuleThe contact point on capsule.
[out]contactNormalThe contact normal that points from capsule to triangle.
[out]penetrationPointCapsuleAxisThe 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 
)
inlineprivate
Parameters
segmentStart[in,out] The start of the line segment
segmentEnd[in,out] The end of the line segment
vThe vertices of the triangle.
planeNNormals of the triangle and each of the edge planes.
planeDd 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 
)
inlineprivate
Parameters
lineStartThe start of the line segment
lineDirThe 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 
)
inlineprivate
Parameters
lineStartThe origin of the line
lineDirUnit 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

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

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

Triangle vertices and normal.

◆ m_tv0

Triangle vertices and normal.

◆ m_tv1

Triangle vertices and normal.

◆ m_tv2

Triangle vertices and normal.


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