81 #define SHAPE_INTERSECT_INVERTED(Shape1, Shape2) \ 83 bool GJKSolver::shapeIntersect<Shape1, Shape2>( \ 84 const Shape1& s1, const Transform3f& tf1, const Shape2& s2, \ 85 const Transform3f& tf2, FCL_REAL& distance_lower_bound, \ 86 bool enable_penetration, Vec3f* contact_points, Vec3f* normal) const { \ 87 bool res = shapeIntersect(s2, tf2, s1, tf1, distance_lower_bound, \ 88 enable_penetration, contact_points, normal); \ 94 bool GJKSolver::shapeIntersect<Sphere, Capsule>(
99 contact_points, normal);
105 bool GJKSolver::shapeIntersect<Sphere, Sphere>(
110 contact_points, normal);
114 bool GJKSolver::shapeIntersect<Box, Sphere>(
117 Vec3f* normal)
const {
120 if (normal) *normal = n;
121 if (contact_points) *contact_points = pb;
142 bool GJKSolver::shapeIntersect<Sphere, Halfspace>(
145 Vec3f* normal)
const {
149 if (contact_points) *contact_points =
p1;
150 if (normal) *normal = n;
157 bool GJKSolver::shapeIntersect<Box, Halfspace>(
160 Vec3f* normal)
const {
164 if (contact_points) *contact_points =
p1;
165 if (normal) *normal = n;
172 bool GJKSolver::shapeIntersect<Capsule, Halfspace>(
175 Vec3f* normal)
const {
179 if (contact_points) *contact_points =
p1;
180 if (normal) *normal = n;
187 bool GJKSolver::shapeIntersect<Cylinder, Halfspace>(
190 Vec3f* normal)
const {
194 if (contact_points) *contact_points =
p1;
195 if (normal) *normal = n;
202 bool GJKSolver::shapeIntersect<Cone, Halfspace>(
205 Vec3f* normal)
const {
209 if (contact_points) *contact_points =
p1;
210 if (normal) *normal = n;
217 bool GJKSolver::shapeIntersect<Halfspace, Halfspace>(
231 bool GJKSolver::shapeIntersect<Plane, Halfspace>(
248 bool GJKSolver::shapeIntersect<Sphere, Plane>(
251 Vec3f* normal)
const {
255 if (contact_points) *contact_points =
p1;
256 if (normal) *normal = n;
263 bool GJKSolver::shapeIntersect<Box, Plane>(
266 Vec3f* normal)
const {
269 if (contact_points) *contact_points =
p1;
270 if (normal) *normal = n;
277 bool GJKSolver::shapeIntersect<Capsule, Plane>(
280 Vec3f* normal)
const {
284 if (contact_points) *contact_points =
p1;
285 if (normal) *normal = n;
292 bool GJKSolver::shapeIntersect<Cylinder, Plane>(
295 Vec3f* normal)
const {
299 if (contact_points) *contact_points =
p1;
300 if (normal) *normal = n;
307 bool GJKSolver::shapeIntersect<Cone, Plane>(
310 Vec3f* normal)
const {
313 if (contact_points) *contact_points =
p1;
314 if (normal) *normal = n;
321 bool GJKSolver::shapeIntersect<Plane, Plane>(
324 Vec3f* normal)
const {
333 Vec3f& p2, Vec3f& normal)
const {
343 FCL_REAL& distance, Vec3f&
p1, Vec3f& p2, Vec3f& normal)
const {
350 const Vec3f&
P1,
const Vec3f&
P2,
354 Vec3f& p2, Vec3f& normal)
const {
384 bool GJKSolver::shapeDistance<Sphere, Capsule>(
const Sphere& s1,
389 Vec3f& p2, Vec3f& normal)
const {
394 bool GJKSolver::shapeDistance<Capsule, Sphere>(
const Capsule& s1,
399 Vec3f& p2, Vec3f& normal)
const {
404 bool GJKSolver::shapeDistance<Box, Sphere>(
const Box& s1,
409 Vec3f& normal)
const {
414 bool GJKSolver::shapeDistance<Sphere, Box>(
const Sphere& s1,
419 Vec3f& normal)
const {
427 bool GJKSolver::shapeDistance<Sphere, Cylinder>(
430 Vec3f& normal)
const {
436 bool GJKSolver::shapeDistance<Cylinder, Sphere>(
439 Vec3f& normal)
const {
445 bool GJKSolver::shapeDistance<Sphere, Sphere>(
const Sphere& s1,
450 Vec3f& p2, Vec3f& normal)
const {
455 bool GJKSolver::shapeDistance<Capsule, Capsule>(
457 const Transform3f& ,
FCL_REAL& , Vec3f& ,
458 Vec3f& , Vec3f& )
const {
463 bool GJKSolver::shapeDistance<TriangleP, TriangleP>(
465 const Transform3f&
tf2, FCL_REAL& dist, Vec3f&
p1, Vec3f& p2,
466 Vec3f& normal)
const {
467 const TriangleP t1(tf1.transform(s1.a), tf1.transform(s1.b),
468 tf1.transform(s1.c)),
469 t2(tf2.transform(s2.a), tf2.transform(s2.b), tf2.transform(s2.c));
475 guess = (t1.a + t1.b + t1.c - t2.a - t2.b - t2.c) / 3;
477 bool enable_penetration =
true;
499 if (enable_penetration) {
501 t1.a, t1.b, t1.c, t2.a, t2.b, t2.c, normal);
502 dist = -penetrationDepth;
503 assert(dist <= 1e-6);
506 return penetrationDepth < 0;
511 assert(
false &&
"should not reach this point");
void initialize_gjk(details::GJK &gjk, const details::MinkowskiDiff &shape, const S1 &s1, const S2 &s2, Vec3f &guess, support_func_guess_t &support_hint) const
initialize GJK
bool planeIntersect(const Plane &s1, const Transform3f &tf1, const Plane &s2, const Transform3f &tf2, Vec3f *, FCL_REAL *, Vec3f *)
bool capsulePlaneIntersect(const Capsule &s1, const Transform3f &tf1, const Plane &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
bool sphereCapsuleDistance(const Sphere &s1, const Transform3f &tf1, const Capsule &s2, const Transform3f &tf2, FCL_REAL &dist, Vec3f &p1, Vec3f &p2, Vec3f &normal)
support_func_guess_t support_hint
bool halfspaceTriangleIntersect(const Halfspace &s1, const Transform3f &tf1, const Vec3f &P1, const Vec3f &P2, const Vec3f &P3, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
#define SHAPE_INTERSECT_INVERTED(Shape1, Shape2)
Cylinder along Z axis. The cylinder is defined at its centroid.
bool conePlaneIntersect(const Cone &s1, const Transform3f &tf1, const Plane &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
bool enable_cached_guess
Whether smart guess can be provided Use gjk_initial_guess instead.
bool cylinderHalfspaceIntersect(const Cylinder &s1, const Transform3f &tf1, const Halfspace &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
bool boxPlaneIntersect(const Box &s1, const Transform3f &tf1, const Plane &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
box half space, a, b, c = +/- edge size n^T * (R(o + a v1 + b v2 + c v3) + T) ~ d so (R^T n) (a v1 + ...
Half Space: this is equivalent to the Plane in ODE. The separation plane is defined as n * x = d; Poi...
bool sphereCapsuleIntersect(const Sphere &s1, const Transform3f &tf1, const Capsule &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f *contact_points, Vec3f *normal_)
bool boxHalfspaceIntersect(const Box &s1, const Transform3f &tf1, const Halfspace &s2, const Transform3f &tf2)
box half space, a, b, c = +/- edge size n^T * (R(o + a v1 + b v2 + c v3) + T) <= d so (R^T n) (a v1 +...
void set(const ShapeBase *shape0, const ShapeBase *shape1)
bool cylinderPlaneIntersect(const Cylinder &s1, const Transform3f &tf1, const Plane &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
cylinder-plane intersect n^T (R (r * cosa * v1 + r * sina * v2 + h * v3) + T) ~ d need one point to b...
bool sphereHalfspaceIntersect(const Sphere &s1, const Transform3f &tf1, const Halfspace &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
Minkowski difference class of two shapes.
bool sphereCylinderDistance(const Sphere &s1, const Transform3f &tf1, const Cylinder &s2, const Transform3f &tf2, FCL_REAL &dist, Vec3f &p1, Vec3f &p2, Vec3f &normal)
bool getClosestPoints(const MinkowskiDiff &shape, Vec3f &w0, Vec3f &w1)
Vec3f getGuessFromSimplex() const
get the guess from current simplex
HPP_FCL_DLLAPI FCL_REAL distance(const Matrix3f &R0, const Vec3f &T0, const kIOS &b1, const kIOS &b2, Vec3f *P=NULL, Vec3f *Q=NULL)
Approximate distance between two kIOS bounding volumes.
bool coneHalfspaceIntersect(const Cone &s1, const Transform3f &tf1, const Halfspace &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
Center at zero point, axis aligned box.
bool halfspaceIntersect(const Halfspace &s1, const Transform3f &tf1, const Halfspace &s2, const Transform3f &tf2, Vec3f &p, Vec3f &d, Halfspace &s, FCL_REAL &penetration_depth, int &ret)
bool capsuleHalfspaceIntersect(const Capsule &s1, const Transform3f &tf1, const Halfspace &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
Status
Status of the GJK algorithm: Valid: GJK converged and the shapes are not in collision. Inside: GJK converged and the shapes are in collision. Failed: GJK did not converge.
bool sphereSphereDistance(const Sphere &s1, const Transform3f &tf1, const Sphere &s2, const Transform3f &tf2, FCL_REAL &dist, Vec3f &p1, Vec3f &p2, Vec3f &normal)
Triangle stores the points instead of only indices of points.
bool sphereSphereIntersect(const Sphere &s1, const Transform3f &tf1, const Sphere &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f *contact_points, Vec3f *normal)
Eigen::Vector2i support_func_guess_t
Cone The base of the cone is at and the top is at .
Center at zero point sphere.
Capsule It is where is the distance between the point x and the capsule segment AB...
Vec3f cached_guess
smart guess
bool spherePlaneIntersect(const Sphere &s1, const Transform3f &tf1, const Plane &s2, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
bool shapeTriangleInteraction(const S &s, const Transform3f &tf1, const Vec3f &P1, const Vec3f &P2, const Vec3f &P3, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal) const
intersection checking between one shape and a triangle with transformation
HPP_FCL_DLLAPI std::size_t collide(const CollisionObject *o1, const CollisionObject *o2, const CollisionRequest &request, CollisionResult &result)
Main collision interface: given two collision objects, and the requirements for contacts, including num of max contacts, whether perform exhaustive collision (i.e., returning returning all the contact points), whether return detailed contact information (i.e., normal, contact point, depth; otherwise only contact primitive id is returned), this function performs the collision between them. Return value is the number of contacts generated between the two objects.
bool planeHalfspaceIntersect(const Plane &s1, const Transform3f &tf1, const Halfspace &s2, const Transform3f &tf2, Plane &pl, Vec3f &p, Vec3f &d, FCL_REAL &penetration_depth, int &ret)
return whether plane collides with halfspace if the separation plane of the halfspace is parallel wit...
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
bool sphereTriangleIntersect(const Sphere &s, const Transform3f &tf1, const Vec3f &P1, const Vec3f &P2, const Vec3f &P3, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal_)
bool planeTriangleIntersect(const Plane &s1, const Transform3f &tf1, const Vec3f &P1, const Vec3f &P2, const Vec3f &P3, const Transform3f &tf2, FCL_REAL &distance, Vec3f &p1, Vec3f &p2, Vec3f &normal)
bool boxSphereDistance(const Box &b, const Transform3f &tfb, const Sphere &s, const Transform3f &tfs, FCL_REAL &dist, Vec3f &pb, Vec3f &ps, Vec3f &normal)
FCL_REAL gjk_tolerance
the threshold used in GJK to stop iteration
support_func_guess_t support_func_cached_guess
smart guess for the support function
size_t gjk_max_iterations
maximum number of iterations used for GJK iterations
FCL_REAL computePenetration(const Vec3f &P1, const Vec3f &P2, const Vec3f &P3, const Vec3f &Q1, const Vec3f &Q2, const Vec3f &Q3, Vec3f &normal)
See the prototype below.
GJKInitialGuess gjk_initial_guess
which warm start to use for GJK
Status evaluate(const MinkowskiDiff &shape, const Vec3f &guess, const support_func_guess_t &supportHint=support_func_guess_t::Zero())
GJK algorithm, given the initial value guess.