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< Vec3 > | simplex_ |
Container to hold the simplex. More... | |
std::vector< Vec3 > | supportA_ |
Container to hold the support points generated in triangle mesh mA. More... | |
std::vector< Vec3 > | supportB_ |
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... | |
|
explicit |
|
inlineprivate |
Calculate closest Point in the simplex and its distance to the origin.
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.
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.
geom1 | support function for the first particle |
geom2 | support function for the second particle |
margin | The margin by which the objects will be enlarged. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
Calculate a support point of a particle extended by a threshold.
geom1 | The body A. |
geom2 | The body B. |
dir | The support point direction. |
margin | The margin by which the objects will be enlarged. |
|
inlineprivate |
Checks if two vectors roughly point in the same direction.
|
private |
Process a simplex with two nodes.
|
private |
Process a simplex with three nodes.
|
private |
Process a simplex with four nodes.
|
inlineprivate |
Checks if the length of a vector is zero or as close to zero that it can not be distinguished form zero.
|
private |
The next search direction.
|
private |
Current number of points in the simplex.
|
private |
Container to hold the simplex.
|
private |
Container to hold the support points generated in triangle mesh mA.
|
private |
Container to hold the support points generated in triangle mesh mB.