waLBerla 7.2
Loading...
Searching...
No Matches
walberla::mesa_pd::collision_detection::EPA Class Reference

Detailed Description

The Expanding-Polytope Algorithm.

#include <EPA.h>

Classes

class  EPA_Edge
 Class storing Information about an Edge of the EPA-Polytope. More...
 
class  EPA_Triangle
 Class storing Information about a triangular facette (Triangle) of the EPA-Polytope. More...
 
class  EPA_TriangleComp
 Compare Triangles by their closest points to sort the triangle heap. More...
 

Public Member Functions

Query functions
bool doEPAcontactThreshold (Support &geom1, Support &geom2, const GJK &gjk, Vec3 &normal, Vec3 &contactPoint, real_t &penetrationDepth)
 Does an EPA computation with contactthreshold added.
 
bool doEPAcontactThreshold (Support &geom1, Support &geom2, const GJK &gjk, Vec3 &normal, Vec3 &contactPoint, real_t &penetrationDepth, real_t eps_rel)
 Does an EPA computation with contactThreshold added.
 
bool doEPAmargin (Support &geom1, Support &geom2, const GJK &gjk, Vec3 &normal, Vec3 &contactPoint, real_t &penetrationDepth, real_t margin)
 Does an EPA computation with margin added.
 
bool doEPA (Support &geom1, Support &geom2, const GJK &gjk, Vec3 &normal, Vec3 &contactPoint, real_t &penetrationDepth, real_t margin, real_t eps_rel)
 Does an epa computation with contact margin added and specified relative error.
 
Getter and Setter functions
void setMaxSupportPoints (size_t maxSupportPoints)
 
size_t getMaxSupportPoints ()
 
void setMaxTriangles (size_t maxTriangles)
 
size_t getMaxTriangles ()
 
int getNumIterations () const
 
bool useSphereOptimization () const
 
void useSphereOptimization (const bool useIt)
 

Static Public Attributes

static constexpr real_t contactThreshold = real_t(1e-8)
 

Private Types

using EPA_EntryBuffer = std::vector<EPA_Triangle>
 
using EPA_EntryHeap = std::vector<EPA_Triangle *>
 
using EPA_EdgeBuffer = std::vector<EPA_Edge>
 

Utility functions

size_t maxSupportPoints_ = 100
 
size_t maxTriangles_ = 200
 
int numIterations_ = 0
 
bool bUseSphereOptimization_ = false
 
void pushSupportMargin (const Support &geom1, const Support &geom2, const Vec3 &dir, const real_t margin, std::vector< Vec3 > &epaVolume, std::vector< Vec3 > &supportA, std::vector< Vec3 > &supportB)
 Calculates a support point of a body extended by threshold.
 
void replaceSupportMargin (const Support &geom1, const Support &geom2, const Vec3 &dir, const real_t margin, std::vector< Vec3 > &epaVolume, std::vector< Vec3 > &supportA, std::vector< Vec3 > &supportB, size_t indexToReplace)
 Calculates a support point of a body extended by threshold.
 
void removeSupportMargin (std::vector< Vec3 > &epaVolume, std::vector< Vec3 > &supportA, std::vector< Vec3 > &supportB)
 Removes a support point from the volume.
 
bool originInTetrahedron (const Vec3 &A, const Vec3 &B, const Vec3 &C, const Vec3 &D)
 TODO.
 
bool originInTetrahedronVolumeMethod (const Vec3 &A, const Vec3 &B, const Vec3 &C, const Vec3 &D)
 Returns true, if the origin lies in the tetrahedron ABCD.
 
bool pointInTetrahedron (const Vec3 &A, const Vec3 &B, const Vec3 &C, const Vec3 &D, const Vec3 &point)
 Returns true, if a point lies in the tetrahedron ABCD.
 
bool searchTetrahedron (Support &geom1, Support &geom2, std::vector< Vec3 > &epaVolume, std::vector< Vec3 > &supportA, std::vector< Vec3 > &supportB, EPA_EntryBuffer &entryBuffer, real_t margin)
 Search a tetrahedron that contains the origin.
 
void createInitialTetrahedron (size_t top, size_t frontLeft, size_t frontRight, size_t back, std::vector< Vec3 > &epaVolume, EPA_EntryBuffer &entryBuffer)
 TODO top, frontLeft ... are indices.
 
void createInitialSimplex (size_t numPoints, Support &geom1, Support &geom2, std::vector< Vec3 > &supportA, std::vector< Vec3 > &supportB, std::vector< Vec3 > &epaVolume, EPA_EntryBuffer &entryBuffer, real_t margin)
 Create a starting tetrahedron for EPA, from the GJK Simplex.
 
real_t calculateCircle (const Vec3 &A, const Vec3 &B, const Vec3 &C, const Vec3 &D, Vec3 &center)
 Calculate a Circle through the for Points A, B, C, D.
 

Member Typedef Documentation

◆ EPA_EdgeBuffer

◆ EPA_EntryBuffer

◆ EPA_EntryHeap

Member Function Documentation

◆ calculateCircle()

real_t walberla::mesa_pd::collision_detection::EPA::calculateCircle ( const Vec3 & A,
const Vec3 & B,
const Vec3 & C,
const Vec3 & D,
Vec3 & center )
inlineprivate

Calculate a Circle through the for Points A, B, C, D.

Parameters
centerContains the center point of the circle after the call
Returns
The squared radius of the circle or a negative value if no such circle exists.

◆ createInitialSimplex()

void walberla::mesa_pd::collision_detection::EPA::createInitialSimplex ( size_t numPoints,
Support & geom1,
Support & geom2,
std::vector< Vec3 > & supportA,
std::vector< Vec3 > & supportB,
std::vector< Vec3 > & epaVolume,
EPA_EntryBuffer & entryBuffer,
real_t margin )
inlineprivate

Create a starting tetrahedron for EPA, from the GJK Simplex.

◆ createInitialTetrahedron()

void walberla::mesa_pd::collision_detection::EPA::createInitialTetrahedron ( size_t top,
size_t frontLeft,
size_t frontRight,
size_t back,
std::vector< Vec3 > & epaVolume,
EPA_EntryBuffer & entryBuffer )
inlineprivate

TODO top, frontLeft ... are indices.

◆ doEPA()

bool walberla::mesa_pd::collision_detection::EPA::doEPA ( Support & geom1,
Support & geom2,
const GJK & gjk,
Vec3 & normal,
Vec3 & contactPoint,
real_t & penetrationDepth,
real_t margin,
real_t eps_rel )

Does an epa computation with contact margin added and specified relative error.

◆ doEPAcontactThreshold() [1/2]

bool walberla::mesa_pd::collision_detection::EPA::doEPAcontactThreshold ( Support & geom1,
Support & geom2,
const GJK & gjk,
Vec3 & retNormal,
Vec3 & contactPoint,
real_t & penetrationDepth )

Does an EPA computation with contactthreshold added.

Use Default relative Error.

◆ doEPAcontactThreshold() [2/2]

bool walberla::mesa_pd::collision_detection::EPA::doEPAcontactThreshold ( Support & geom1,
Support & geom2,
const GJK & gjk,
Vec3 & retNormal,
Vec3 & contactPoint,
real_t & penetrationDepth,
real_t eps_rel )

Does an EPA computation with contactThreshold added.

Relative Error can be specified.

◆ doEPAmargin()

bool walberla::mesa_pd::collision_detection::EPA::doEPAmargin ( Support & geom1,
Support & geom2,
const GJK & gjk,
Vec3 & retNormal,
Vec3 & contactPoint,
real_t & penetrationDepth,
real_t margin )

Does an EPA computation with margin added.

Use Default relative Error.

◆ getMaxSupportPoints()

size_t walberla::mesa_pd::collision_detection::EPA::getMaxSupportPoints ( )
inline

◆ getMaxTriangles()

size_t walberla::mesa_pd::collision_detection::EPA::getMaxTriangles ( )
inline

◆ getNumIterations()

int walberla::mesa_pd::collision_detection::EPA::getNumIterations ( ) const
inline

◆ originInTetrahedron()

bool walberla::mesa_pd::collision_detection::EPA::originInTetrahedron ( const Vec3 & p0,
const Vec3 & p1,
const Vec3 & p2,
const Vec3 & p3 )
inlineprivate

TODO.

see Book "collision detection in interactive 3D environments" page161 ATTENTION seems to have no consistent behavior on the surface and vertices

◆ originInTetrahedronVolumeMethod()

bool walberla::mesa_pd::collision_detection::EPA::originInTetrahedronVolumeMethod ( const Vec3 & A,
const Vec3 & B,
const Vec3 & C,
const Vec3 & D )
inlineprivate

Returns true, if the origin lies in the tetrahedron ABCD.

◆ pointInTetrahedron()

bool walberla::mesa_pd::collision_detection::EPA::pointInTetrahedron ( const Vec3 & A,
const Vec3 & B,
const Vec3 & C,
const Vec3 & D,
const Vec3 & point )
inlineprivate

Returns true, if a point lies in the tetrahedron ABCD.

Parameters
pointThe point to be checked for containment.

◆ pushSupportMargin()

void walberla::mesa_pd::collision_detection::EPA::pushSupportMargin ( const Support & geom1,
const Support & geom2,
const Vec3 & dir,
const real_t margin,
std::vector< Vec3 > & epaVolume,
std::vector< Vec3 > & supportA,
std::vector< Vec3 > & supportB )
inlineprivate

Calculates a support point of a body extended by threshold.

Adds this support and the base points at bodies A and B to the vector.

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

◆ removeSupportMargin()

void walberla::mesa_pd::collision_detection::EPA::removeSupportMargin ( std::vector< Vec3 > & epaVolume,
std::vector< Vec3 > & supportA,
std::vector< Vec3 > & supportB )
inlineprivate

Removes a support point from the volume.

◆ replaceSupportMargin()

void walberla::mesa_pd::collision_detection::EPA::replaceSupportMargin ( const Support & geom1,
const Support & geom2,
const Vec3 & dir,
const real_t margin,
std::vector< Vec3 > & epaVolume,
std::vector< Vec3 > & supportA,
std::vector< Vec3 > & supportB,
size_t indexToReplace )
inlineprivate

Calculates a support point of a body extended by threshold.

Replaces the old value in the vectors at "IndexToReplace" with this support and the base points at bodies A and B.

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

◆ searchTetrahedron()

bool walberla::mesa_pd::collision_detection::EPA::searchTetrahedron ( Support & geom1,
Support & geom2,
std::vector< Vec3 > & epaVolume,
std::vector< Vec3 > & supportA,
std::vector< Vec3 > & supportB,
EPA_EntryBuffer & entryBuffer,
real_t margin )
inlineprivate

Search a tetrahedron that contains the origin.

Start with four arbitrary support points in epaVolume that form a tetrahedron. (This needn't contain the origin.) This algorithm will search and return an altered tetrahedron containing the origin. Do only use this function if the object/body certainly contains the origin!

Returns
True, if a tetrahedron was found. False if search has been aborted.

◆ setMaxSupportPoints()

void walberla::mesa_pd::collision_detection::EPA::setMaxSupportPoints ( size_t maxSupportPoints)
inline

◆ setMaxTriangles()

void walberla::mesa_pd::collision_detection::EPA::setMaxTriangles ( size_t maxTriangles)
inline

◆ useSphereOptimization() [1/2]

bool walberla::mesa_pd::collision_detection::EPA::useSphereOptimization ( ) const
inline

◆ useSphereOptimization() [2/2]

void walberla::mesa_pd::collision_detection::EPA::useSphereOptimization ( const bool useIt)
inline

Member Data Documentation

◆ bUseSphereOptimization_

bool walberla::mesa_pd::collision_detection::EPA::bUseSphereOptimization_ = false
private

◆ contactThreshold

real_t walberla::mesa_pd::collision_detection::EPA::contactThreshold = real_t(1e-8)
staticconstexpr

◆ maxSupportPoints_

size_t walberla::mesa_pd::collision_detection::EPA::maxSupportPoints_ = 100
private

◆ maxTriangles_

size_t walberla::mesa_pd::collision_detection::EPA::maxTriangles_ = 200
private

◆ numIterations_

int walberla::mesa_pd::collision_detection::EPA::numIterations_ = 0
private

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