walberla::pe::fcd::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 (GeomPrimitive &geom1, GeomPrimitive &geom2, Vec3 &normal, Vec3 &contactPoint)
 Calculate an upper bound for the distance of two Geometries. More...
 
bool doGJKmargin (GeomPrimitive &geom1, GeomPrimitive &geom2, const real_t margin=contactThreshold)
 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 directionTODO. More...
 
bool zeroLengthVector (const Vec3 &vec) const
 
real_t calcDistance (Vec3 &normal, Vec3 &contactPoint)
 Calculate closest Point in the simplex and its distance to the origin. More...
 
const Vec3 putSupport (const GeomPrimitive &geom1, const GeomPrimitive &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 body extended by a threshold. More...
 

Private Attributes

Member variables
std::vector< Vec3simplex_
 
std::vector< Vec3supportA_
 
std::vector< Vec3supportB_
 
unsigned char numPoints_
 
Vec3 d_
 

Constructor & Destructor Documentation

◆ GJK()

walberla::pe::fcd::GJK::GJK ( )
inlineexplicit

Member Function Documentation

◆ calcDistance()

real_t walberla::pe::fcd::GJK::calcDistance ( Vec3 normal,
Vec3 contactPoint 
)
inlineprivate

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

◆ doGJK()

real_t walberla::pe::fcd::GJK::doGJK ( GeomPrimitive geom1,
GeomPrimitive 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::pe::fcd::GJK::doGJKmargin ( GeomPrimitive geom1,
GeomPrimitive geom2,
const real_t  margin = contactThreshold 
)

Compute if two geometries intersect.

Both can be enlarged by a specified margin.

Parameters
geom1The first Body
geom2The second Body
marginThe margin by which the objects will be enlarged.
Returns
true, if an intersection is found.

◆ getSimplex()

const std::vector< Vec3 > & walberla::pe::fcd::GJK::getSimplex ( ) const
inline

◆ getSimplexSize()

size_t walberla::pe::fcd::GJK::getSimplexSize ( ) const
inline

◆ getSupportA()

const std::vector< Vec3 > & walberla::pe::fcd::GJK::getSupportA ( ) const
inline

◆ getSupportB()

const std::vector< Vec3 > & walberla::pe::fcd::GJK::getSupportB ( ) const
inline

◆ putSupport()

const Vec3 walberla::pe::fcd::GJK::putSupport ( const GeomPrimitive geom1,
const GeomPrimitive 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 body extended by a threshold.

Parameters
geom1The body A.
geom2The body B.
dirThe support point direction.
marginExtension of the Body.

◆ sameDirection()

bool walberla::pe::fcd::GJK::sameDirection ( const Vec3 vec1,
const Vec3 vec2 
) const
inlineprivate

Checks if two vectors roughly point in the same directionTODO.

◆ simplex2()

bool walberla::pe::fcd::GJK::simplex2 ( Vec3 d)
private

Process a simplex with two nodes.

◆ simplex3()

bool walberla::pe::fcd::GJK::simplex3 ( Vec3 d)
private

Process a simplex with three nodes.

◆ simplex4()

bool walberla::pe::fcd::GJK::simplex4 ( Vec3 d)
private

Process a simplex with four nodes.

◆ zeroLengthVector()

bool walberla::pe::fcd::GJK::zeroLengthVector ( const Vec3 vec) const
inlineprivate

Member Data Documentation

◆ d_

Vec3 walberla::pe::fcd::GJK::d_
private

◆ numPoints_

unsigned char walberla::pe::fcd::GJK::numPoints_
private

◆ simplex_

std::vector<Vec3> walberla::pe::fcd::GJK::simplex_
private

◆ supportA_

std::vector<Vec3> walberla::pe::fcd::GJK::supportA_
private

◆ supportB_

std::vector<Vec3> walberla::pe::fcd::GJK::supportB_
private

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