walberla::mesa_pd::collision_detection::GJK Class Reference

Detailed Description

Implementation of the Gilbert-Johnson-Keerthi Algorithm.

#include <GJK.h>

Public Member Functions

Constructor
 GJK ()
 
Query functions
real_t doGJK (const Support &geom1, const Support &geom2, Vec3 &normal, Vec3 &contactPoint)
 Calculate an upper bound for the distance of two Geometries. More...
 
bool doGJKmargin (const Support &geom1, const Support &geom2, const real_t margin=real_t(0))
 Compute if two geometries intersect. More...
 
Get functions
const std::vector< Vec3 > & getSimplex () const
 
size_t getSimplexSize () const
 
const std::vector< Vec3 > & getSupportA () const
 
const std::vector< Vec3 > & getSupportB () const
 

Private Member Functions

Utility functions
bool simplex2 (Vec3 &d)
 Process a simplex with two nodes. More...
 
bool simplex3 (Vec3 &d)
 Process a simplex with three nodes. More...
 
bool simplex4 (Vec3 &d)
 Process a simplex with four nodes. More...
 
bool sameDirection (const Vec3 &vec1, const Vec3 &vec2) const
 Checks if two vectors roughly point in the same direction. More...
 
bool zeroLengthVector (const Vec3 &vec) const
 Checks if the length of a vector is zero or as close to zero that it can not be distinguished form zero. More...
 
real_t calcDistance (Vec3 &normal, Vec3 &contactPoint)
 Calculate closest Point in the simplex and its distance to the origin. More...
 
Vec3 putSupport (const Support &geom1, const Support &geom2, const Vec3 &dir, const real_t margin, std::vector< Vec3 > &simplex, std::vector< Vec3 > &supportA, std::vector< Vec3 > &supportB, size_t index)
 Calculate a support point of a particle extended by a threshold. More...
 

Private Attributes

Member variables
std::vector< Vec3simplex_
 Container to hold the simplex. More...
 
std::vector< Vec3supportA_
 Container to hold the support points generated in triangle mesh mA. More...
 
std::vector< Vec3supportB_
 Container to hold the support points generated in triangle mesh mB. More...
 
unsigned char numPoints_
 Current number of points in the simplex. More...
 
Vec3 d_
 The next search direction. More...
 

Constructor & Destructor Documentation

◆ GJK()

walberla::mesa_pd::collision_detection::GJK::GJK ( )
explicit

Member Function Documentation

◆ calcDistance()

real_t walberla::mesa_pd::collision_detection::GJK::calcDistance ( Vec3 normal,
Vec3 contactPoint 
)
inlineprivate

Calculate closest Point in the simplex and its distance to the origin.

◆ doGJK()

real_t walberla::mesa_pd::collision_detection::GJK::doGJK ( const Support geom1,
const Support geom2,
Vec3 normal,
Vec3 contactPoint 
)

Calculate an upper bound for the distance of two Geometries.

Returns
Distance between geom1 and geom2 or 0.0 if they are intersecting.

◆ doGJKmargin()

bool walberla::mesa_pd::collision_detection::GJK::doGJKmargin ( const Support geom1,
const Support geom2,
const real_t  margin = real_t(0) 
)

Compute if two geometries intersect.

Both can be enlarged by a specified margin.

Parameters
geom1support function for the first particle
geom2support function for the second particle
marginThe margin by which the objects will be enlarged.
Returns
true, if an intersection is found.

◆ getSimplex()

const std::vector<Vec3>& walberla::mesa_pd::collision_detection::GJK::getSimplex ( ) const
inline

◆ getSimplexSize()

size_t walberla::mesa_pd::collision_detection::GJK::getSimplexSize ( ) const
inline

◆ getSupportA()

const std::vector<Vec3>& walberla::mesa_pd::collision_detection::GJK::getSupportA ( ) const
inline

◆ getSupportB()

const std::vector<Vec3>& walberla::mesa_pd::collision_detection::GJK::getSupportB ( ) const
inline

◆ putSupport()

Vec3 walberla::mesa_pd::collision_detection::GJK::putSupport ( const Support geom1,
const Support geom2,
const Vec3 dir,
const real_t  margin,
std::vector< Vec3 > &  simplex,
std::vector< Vec3 > &  supportA,
std::vector< Vec3 > &  supportB,
size_t  index 
)
inlineprivate

Calculate a support point of a particle extended by a threshold.

Parameters
geom1The body A.
geom2The body B.
dirThe support point direction.
marginThe margin by which the objects will be enlarged.

◆ sameDirection()

bool walberla::mesa_pd::collision_detection::GJK::sameDirection ( const Vec3 vec1,
const Vec3 vec2 
) const
inlineprivate

Checks if two vectors roughly point in the same direction.

◆ simplex2()

bool walberla::mesa_pd::collision_detection::GJK::simplex2 ( Vec3 d)
private

Process a simplex with two nodes.

◆ simplex3()

bool walberla::mesa_pd::collision_detection::GJK::simplex3 ( Vec3 d)
private

Process a simplex with three nodes.

◆ simplex4()

bool walberla::mesa_pd::collision_detection::GJK::simplex4 ( Vec3 d)
private

Process a simplex with four nodes.

◆ zeroLengthVector()

bool walberla::mesa_pd::collision_detection::GJK::zeroLengthVector ( const Vec3 vec) const
inlineprivate

Checks if the length of a vector is zero or as close to zero that it can not be distinguished form zero.

Member Data Documentation

◆ d_

Vec3 walberla::mesa_pd::collision_detection::GJK::d_
private

The next search direction.

◆ numPoints_

unsigned char walberla::mesa_pd::collision_detection::GJK::numPoints_
private

Current number of points in the simplex.

◆ simplex_

std::vector<Vec3> walberla::mesa_pd::collision_detection::GJK::simplex_
private

Container to hold the simplex.

◆ supportA_

std::vector<Vec3> walberla::mesa_pd::collision_detection::GJK::supportA_
private

Container to hold the support points generated in triangle mesh mA.

◆ supportB_

std::vector<Vec3> walberla::mesa_pd::collision_detection::GJK::supportB_
private

Container to hold the support points generated in triangle mesh mB.


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