Skip to content

Commit db3b692

Browse files
committed
Do not throw an error when the origin may be outside the polytope in EPA.
Turns out the origin can be slightly outside of the polytope due to numerical errors, so we do not throw the error any more.
1 parent b03987c commit db3b692

File tree

2 files changed

+882
-28
lines changed

2 files changed

+882
-28
lines changed

include/fcl/narrowphase/detail/convexity_based_algorithm/gjk_libccd-inl.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ static ccd_vec3_t faceNormalPointingOutward(const ccd_pt_t* polytope,
10851085
}
10861086

10871087
// Return true if the point `pt` is on the outward side of the half-plane, on
1088-
// which the triangle `f1 lives. Notice if the point `pt` is exactly on the
1088+
// which the triangle `f` lives. Notice if the point `pt` is exactly on the
10891089
// half-plane, the return is false.
10901090
// @param f A triangle on a polytope.
10911091
// @param pt A point.
@@ -1688,14 +1688,6 @@ static void validateNearestFeatureOfPolytopeBeingEdge(ccd_pt_t* polytope) {
16881688
std::array<ccd_vec3_t, 2> face_normals;
16891689
std::array<double, 2> origin_to_face_distance;
16901690

1691-
// We define the plane equation using vertex[0]. If vertex[0] is far away
1692-
// from the origin, it can magnify rounding error. We scale epsilon to account
1693-
// for this possibility.
1694-
const ccd_real_t v0_dist =
1695-
std::sqrt(ccdVec3Len2(&nearest_edge->vertex[0]->v.v));
1696-
const ccd_real_t plane_threshold =
1697-
kEps * std::max(static_cast<ccd_real_t>(1.0), v0_dist);
1698-
16991691
for (int i = 0; i < 2; ++i) {
17001692
face_normals[i] =
17011693
faceNormalPointingOutward(polytope, nearest_edge->faces[i]);
@@ -1704,22 +1696,6 @@ static void validateNearestFeatureOfPolytopeBeingEdge(ccd_pt_t* polytope) {
17041696
// n̂ ⋅ (o - vₑ) ≤ 0 or, with simplification, -n̂ ⋅ vₑ ≤ 0 (since n̂ ⋅ o = 0).
17051697
origin_to_face_distance[i] =
17061698
-ccdVec3Dot(&face_normals[i], &nearest_edge->vertex[0]->v.v);
1707-
// If the origin lies *on* the edge, then it also lies on the two adjacent
1708-
// faces. Rather than failing on strictly *positive* signed distance, we
1709-
// introduce an epsilon threshold. This usage of epsilon is to account for a
1710-
// discrepancy in the signed distance computation. How GJK (and partially
1711-
// EPA) compute the signed distance from origin to face may *not* be exactly
1712-
// the same as done in this test (i.e. for a given set of vertices, the
1713-
// plane equation can be defined various ways. Those ways are
1714-
// *mathematically* equivalent but numerically will differ due to rounding).
1715-
// We account for those differences by allowing a very small positive signed
1716-
// distance to be considered zero. We assume that the GJK/EPA code
1717-
// ultimately classifies inside/outside around *zero* and *not* epsilon.
1718-
if (origin_to_face_distance[i] > plane_threshold) {
1719-
FCL_THROW_FAILED_AT_THIS_CONFIGURATION(
1720-
"The origin is outside of the polytope. This should already have "
1721-
"been identified as separating.");
1722-
}
17231699
}
17241700

17251701
// We know the reported squared distance to the edge. If that distance is

0 commit comments

Comments
 (0)