#include <GJKClosestPoint.h>

template<typename A , typename B > 
bool  Intersects (const A &inA, const B &inB, float inTolerance, Vec3 &ioV) 

template<typename A , typename B > 
float  GetClosestPoints (const A &inA, const B &inB, float inTolerance, float inMaxDistSq, Vec3 &ioV, Vec3 &outPointA, Vec3 &outPointB) 

void  GetClosestPointsSimplex (Vec3 *outY, Vec3 *outP, Vec3 *outQ, uint &outNumPoints) const 

template<typename A > 
bool  CastRay (Vec3Arg inRayOrigin, Vec3Arg inRayDirection, float inTolerance, const A &inA, float &ioLambda) 

template<typename A , typename B > 
bool  CastShape (Mat44Arg inStart, Vec3Arg inDirection, float inTolerance, const A &inA, const B &inB, float &ioLambda) 

template<typename A , typename B > 
bool  CastShape (Mat44Arg inStart, Vec3Arg inDirection, float inTolerance, const A &inA, const B &inB, float inConvexRadiusA, float inConvexRadiusB, float &ioLambda, Vec3 &outPointA, Vec3 &outPointB, Vec3 &outSeparatingAxis) 

 NonCopyable ()=default 

 NonCopyable (const NonCopyable &)=delete 

void  operator= (const NonCopyable &)=delete 

Convex vs convex collision detection Based on: A Fast and Robust GJK Implementation for Collision Detection of Convex Objects  Gino van den Bergen
◆ CastRay()
template<typename A >
bool GJKClosestPoint::CastRay 
( 
Vec3Arg 
inRayOrigin, 


Vec3Arg 
inRayDirection, 


float 
inTolerance, 


const A & 
inA, 


float & 
ioLambda 

) 
 

inline 
Test if a ray inRayOrigin + lambda * inRayDirection for lambda e [0, ioLambda> intersects inA
Code based upon: Ray Casting against General Convex Objects with Application to Continuous Collision Detection  Gino van den Bergen
 Parameters

inRayOrigin  Origin of the ray 
inRayDirection  Direction of the ray (ioLambda * inDirection determines length) 
inTolerance  The minimal distance between the ray and A before it is considered colliding 
inA  A convex object that has the GetSupport(Vec3) function 
ioLambda  The max fraction along the ray, on output updated with the actual collision fraction. 
 Returns
 true if a hit was found, ioLambda is the solution for lambda.
◆ CastShape() [1/2]
template<typename A , typename B >
bool GJKClosestPoint::CastShape 
( 
Mat44Arg 
inStart, 


Vec3Arg 
inDirection, 


float 
inTolerance, 


const A & 
inA, 


const B & 
inB, 


float & 
ioLambda 

) 
 

inline 
Test if a cast shape inA moving from inStart to lambda * inStart.GetTranslation() + inDirection where lambda e [0, ioLambda> intersects inB
 Parameters

inStart  Start position and orientation of the convex object 
inDirection  Direction of the sweep (ioLambda * inDirection determines length) 
inTolerance  The minimal distance between A and B before they are considered colliding 
inA  The convex object A, must support the GetSupport(Vec3) function. 
inB  The convex object B, must support the GetSupport(Vec3) function. 
ioLambda  The max fraction along the sweep, on output updated with the actual collision fraction. 
 Returns
 true if a hit was found, ioLambda is the solution for lambda.
◆ CastShape() [2/2]
template<typename A , typename B >
bool GJKClosestPoint::CastShape 
( 
Mat44Arg 
inStart, 


Vec3Arg 
inDirection, 


float 
inTolerance, 


const A & 
inA, 


const B & 
inB, 


float 
inConvexRadiusA, 


float 
inConvexRadiusB, 


float & 
ioLambda, 


Vec3 & 
outPointA, 


Vec3 & 
outPointB, 


Vec3 & 
outSeparatingAxis 

) 
 

inline 
Test if a cast shape inA moving from inStart to lambda * inStart.GetTranslation() + inDirection where lambda e [0, ioLambda> intersects inB
 Parameters

inStart  Start position and orientation of the convex object 
inDirection  Direction of the sweep (ioLambda * inDirection determines length) 
inTolerance  The minimal distance between A and B before they are considered colliding 
inA  The convex object A, must support the GetSupport(Vec3) function. 
inB  The convex object B, must support the GetSupport(Vec3) function. 
inConvexRadiusA  The convex radius of A, this will be added on all sides to pad A. 
inConvexRadiusB  The convex radius of B, this will be added on all sides to pad B. 
ioLambda  The max fraction along the sweep, on output updated with the actual collision fraction. 
outPointA  is the contact point on A (if outSeparatingAxis is near zero, this may not be not the deepest point) 
outPointB  is the contact point on B (if outSeparatingAxis is near zero, this may not be not the deepest point) 
outSeparatingAxis  On return this will contain a vector that points from A to B along the smallest distance of separation. The length of this vector indicates the separation of A and B without their convex radius. If it is near zero, the direction may not be accurate as the bodies may overlap when lambda = 0. 
 Returns
 true if a hit was found, ioLambda is the solution for lambda and outPoint and outSeparatingAxis are valid.
◆ GetClosestPoints()
template<typename A , typename B >
float GJKClosestPoint::GetClosestPoints 
( 
const A & 
inA, 


const B & 
inB, 


float 
inTolerance, 


float 
inMaxDistSq, 


Vec3 & 
ioV, 


Vec3 & 
outPointA, 


Vec3 & 
outPointB 

) 
 

inline 
Get closest points between inA and inB
 Parameters

inA  The convex object A, must support the GetSupport(Vec3) function. 
inB  The convex object B, must support the GetSupport(Vec3) function. 
inTolerance  The minimal distance between A and B before the objects are considered colliding and processing is terminated. 
inMaxDistSq  The maximum squared distance between A and B before the objects are considered infinitely far away and processing is terminated. 
ioV  Initial guess for the separating axis. Start with any nonzero vector if you don't know. If return value is 0, ioV = (0, 0, 0). If the return value is bigger than 0 but smaller than FLT_MAX, ioV will be the separating axis in the direction from A to B and its length the squared distance between A and B. If the return value is FLT_MAX, ioV will be the separating axis in the direction from A to B and the magnitude of the vector is meaningless. 
outPointA,outPointB  If the return value is 0 the points are invalid. If the return value is bigger than 0 but smaller than FLT_MAX these will contain the closest point on A and B. If the return value is FLT_MAX the points are invalid. 
 Returns
 The squared distance between A and B or FLT_MAX when they are further away than inMaxDistSq.
◆ GetClosestPointsSimplex()
void GJKClosestPoint::GetClosestPointsSimplex 
( 
Vec3 * 
outY, 


Vec3 * 
outP, 


Vec3 * 
outQ, 


uint & 
outNumPoints 

) 
 const 

inline 
Get the resulting simplex after the GetClosestPoints algorithm finishes. If it returned a squared distance of 0, the origin will be contained in the simplex.
◆ Intersects()
template<typename A , typename B >
bool GJKClosestPoint::Intersects 
( 
const A & 
inA, 


const B & 
inB, 


float 
inTolerance, 


Vec3 & 
ioV 

) 
 

inline 
Test if inA and inB intersect
 Parameters

inA  The convex object A, must support the GetSupport(Vec3) function. 
inB  The convex object B, must support the GetSupport(Vec3) function. 
inTolerance  Minimal distance between objects when the objects are considered to be colliding 
ioV  is used as initial separating axis (provide a zero vector if you don't know yet) 
 Returns
 True if they intersect (in which case ioV = (0, 0, 0)). False if they don't intersect in which case ioV is a separating axis in the direction from A to B (magnitude is meaningless)
The documentation for this class was generated from the following file: