walberla::pe::fcd::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 (GeomPrimitive &geom1, GeomPrimitive &geom2, const GJK &gjk, Vec3 &normal, Vec3 &contactPoint, real_t &penetrationDepth)
 Does an EPA computation with contactthreshold added. More...
 
bool doEPAcontactThreshold (GeomPrimitive &geom1, GeomPrimitive &geom2, const GJK &gjk, Vec3 &normal, Vec3 &contactPoint, real_t &penetrationDepth, real_t eps_rel)
 Does an EPA computation with contactThreshold added. More...
 
bool doEPAmargin (GeomPrimitive &geom1, GeomPrimitive &geom2, const GJK &gjk, Vec3 &normal, Vec3 &contactPoint, real_t &penetrationDepth, real_t margin)
 Does an EPA computation with margin added. More...
 
bool doEPA (GeomPrimitive &geom1, GeomPrimitive &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. More...
 
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)
 

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 GeomPrimitive &geom1, const GeomPrimitive &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. More...
 
void replaceSupportMargin (const GeomPrimitive &geom1, const GeomPrimitive &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. More...
 
void removeSupportMargin (std::vector< Vec3 > &epaVolume, std::vector< Vec3 > &supportA, std::vector< Vec3 > &supportB)
 Removes a support point from the volume. More...
 
bool originInTetrahedron (const Vec3 &A, const Vec3 &B, const Vec3 &C, const Vec3 &D)
 TODO. More...
 
bool originInTetrahedronVolumeMethod (const Vec3 &A, const Vec3 &B, const Vec3 &C, const Vec3 &D)
 Returns true, if the origin lies in the tetrahedron ABCD. More...
 
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. More...
 
bool searchTetrahedron (GeomPrimitive &geom1, GeomPrimitive &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. More...
 
void createInitialTetrahedron (size_t top, size_t frontLeft, size_t frontRight, size_t back, std::vector< Vec3 > &epaVolume, EPA_EntryBuffer &entryBuffer)
 TODO top, frontLeft ... More...
 
void createInitialSimplex (size_t numPoints, GeomPrimitive &geom1, GeomPrimitive &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. More...
 
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. More...
 

Member Typedef Documentation

◆ EPA_EdgeBuffer

using walberla::pe::fcd::EPA::EPA_EdgeBuffer = std::vector<EPA_Edge>
private

◆ EPA_EntryBuffer

◆ EPA_EntryHeap

using walberla::pe::fcd::EPA::EPA_EntryHeap = std::vector<EPA_Triangle *>
private

Member Function Documentation

◆ calculateCircle()

real_t walberla::pe::fcd::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::pe::fcd::EPA::createInitialSimplex ( size_t  numPoints,
GeomPrimitive geom1,
GeomPrimitive 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::pe::fcd::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::pe::fcd::EPA::doEPA ( GeomPrimitive geom1,
GeomPrimitive 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::pe::fcd::EPA::doEPAcontactThreshold ( GeomPrimitive geom1,
GeomPrimitive 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::pe::fcd::EPA::doEPAcontactThreshold ( GeomPrimitive geom1,
GeomPrimitive 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::pe::fcd::EPA::doEPAmargin ( GeomPrimitive geom1,
GeomPrimitive 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::pe::fcd::EPA::getMaxSupportPoints ( )
inline

◆ getMaxTriangles()

size_t walberla::pe::fcd::EPA::getMaxTriangles ( )
inline

◆ getNumIterations()

int walberla::pe::fcd::EPA::getNumIterations ( ) const
inline

◆ originInTetrahedron()

bool walberla::pe::fcd::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::pe::fcd::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::pe::fcd::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::pe::fcd::EPA::pushSupportMargin ( const GeomPrimitive geom1,
const GeomPrimitive 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::pe::fcd::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::pe::fcd::EPA::replaceSupportMargin ( const GeomPrimitive geom1,
const GeomPrimitive 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::pe::fcd::EPA::searchTetrahedron ( GeomPrimitive geom1,
GeomPrimitive 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::pe::fcd::EPA::setMaxSupportPoints ( size_t  maxSupportPoints)
inline

◆ setMaxTriangles()

void walberla::pe::fcd::EPA::setMaxTriangles ( size_t  maxTriangles)
inline

◆ useSphereOptimization() [1/2]

bool walberla::pe::fcd::EPA::useSphereOptimization ( ) const
inline

◆ useSphereOptimization() [2/2]

void walberla::pe::fcd::EPA::useSphereOptimization ( const bool  useIt)
inline

Member Data Documentation

◆ bUseSphereOptimization_

bool walberla::pe::fcd::EPA::bUseSphereOptimization_ = false
private

◆ maxSupportPoints_

size_t walberla::pe::fcd::EPA::maxSupportPoints_ = 100
private

◆ maxTriangles_

size_t walberla::pe::fcd::EPA::maxTriangles_ = 200
private

◆ numIterations_

int walberla::pe::fcd::EPA::numIterations_ = 0
private

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