Skip to content

Commit cf1725d

Browse files
lmontautjcarpent
authored andcommitted
test: more robust geometric_shapes test for cylinder-plane
1 parent 6c3cdfb commit cf1725d

File tree

1 file changed

+76
-17
lines changed

1 file changed

+76
-17
lines changed

test/geometric_shapes.cpp

+76-17
Original file line numberDiff line numberDiff line change
@@ -2084,21 +2084,41 @@ BOOST_AUTO_TEST_CASE(shapeIntersection_planecylinder) {
20842084
Vec3f normal;
20852085
Vec3f p1, p2;
20862086

2087-
tf1 = Transform3f();
2087+
FCL_REAL eps = 1e-6;
2088+
tf1 = Transform3f(Vec3f(eps, 0, 0));
20882089
tf2 = Transform3f();
2089-
p1 << -5, 0, 0;
2090+
p1 << -5 + eps, 0, 0;
20902091
p2 << 0, 0, 0;
20912092
contact << (p1 + p2) / 2;
2092-
depth = -5;
2093+
depth = -5 + eps;
20932094
normal << -1, 0, 0; // (1, 0, 0) or (-1, 0, 0)
20942095
SET_LINE;
20952096
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
20962097

2097-
tf1 = transform;
2098+
tf1 = transform * tf1;
20982099
tf2 = transform;
2099-
p1 << 5, 0, 0;
21002100
contact = transform.transform((p1 + p2) / 2);
2101-
depth = -5;
2101+
depth = -5 + eps;
2102+
normal =
2103+
transform.getRotation() * Vec3f(-1, 0, 0); // (1, 0, 0) or (-1, 0, 0)
2104+
SET_LINE;
2105+
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
2106+
2107+
eps = -1e-6;
2108+
tf1 = Transform3f(Vec3f(eps, 0, 0));
2109+
tf2 = Transform3f();
2110+
p1 << 5 + eps, 0, 0;
2111+
p2 << 0, 0, 0;
2112+
contact << (p1 + p2) / 2;
2113+
depth = -5 - eps;
2114+
normal << -1, 0, 0; // (1, 0, 0) or (-1, 0, 0)
2115+
SET_LINE;
2116+
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
2117+
2118+
tf1 = transform * tf1;
2119+
tf2 = transform;
2120+
contact = transform.transform((p1 + p2) / 2);
2121+
depth = -5 - eps;
21022122
normal =
21032123
transform.getRotation() * Vec3f(-1, 0, 0); // (1, 0, 0) or (-1, 0, 0)
21042124
SET_LINE;
@@ -2162,21 +2182,40 @@ BOOST_AUTO_TEST_CASE(shapeIntersection_planecylinder) {
21622182

21632183
hs = Plane(Vec3f(0, 1, 0), 0);
21642184

2165-
tf1 = Transform3f();
2185+
eps = 1e-6;
2186+
tf1 = Transform3f(Vec3f(0, eps, 0));
21662187
tf2 = Transform3f();
2167-
p1 << 0, -5, 0;
2188+
p1 << 0, -5 + eps, 0;
21682189
p2 << 0, 0, 0;
21692190
contact << (p1 + p2) / 2;
2170-
depth = -5;
2191+
depth = -5 + eps;
21712192
normal << 0, 1, 0; // (1, 0, 0) or (-1, 0, 0)
21722193
SET_LINE;
21732194
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
21742195

2175-
tf1 = transform;
2196+
tf1 = transform * tf1;
21762197
tf2 = transform;
2177-
p1 << 0, 5, 0;
21782198
contact = transform.transform((p1 + p2) / 2);
2179-
depth = -5;
2199+
depth = -5 + eps;
2200+
normal = transform.getRotation() * Vec3f(0, 1, 0); // (1, 0, 0) or (-1, 0, 0)
2201+
SET_LINE;
2202+
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
2203+
2204+
eps = -1e-6;
2205+
tf1 = Transform3f(Vec3f(0, eps, 0));
2206+
tf2 = Transform3f();
2207+
p1 << 0, 5 + eps, 0;
2208+
p2 << 0, 0, 0;
2209+
contact << (p1 + p2) / 2;
2210+
depth = -5 - eps;
2211+
normal << 0, 1, 0; // (1, 0, 0) or (-1, 0, 0)
2212+
SET_LINE;
2213+
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
2214+
2215+
tf1 = transform * tf1;
2216+
tf2 = transform;
2217+
contact = transform.transform((p1 + p2) / 2);
2218+
depth = -5 - eps;
21802219
normal = transform.getRotation() * Vec3f(0, 1, 0); // (1, 0, 0) or (-1, 0, 0)
21812220
SET_LINE;
21822221
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
@@ -2239,20 +2278,40 @@ BOOST_AUTO_TEST_CASE(shapeIntersection_planecylinder) {
22392278

22402279
hs = Plane(Vec3f(0, 0, 1), 0);
22412280

2242-
tf1 = Transform3f();
2281+
eps = 1e-6;
2282+
tf1 = Transform3f(Vec3f(0, 0, eps));
22432283
tf2 = Transform3f();
2244-
p1 << 0, 0, 5;
2284+
p1 << 0, 0, -5 + eps;
22452285
p2 << 0, 0, 0;
22462286
contact << (p1 + p2) / 2;
2247-
depth = -5;
2287+
depth = -5 + eps;
22482288
normal << 0, 0, 1; // (1, 0, 0) or (-1, 0, 0)
22492289
SET_LINE;
22502290
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
22512291

2252-
tf1 = transform;
2292+
tf1 = transform * tf1;
22532293
tf2 = transform;
22542294
contact = transform.transform((p1 + p2) / 2);
2255-
depth = -5;
2295+
depth = -5 + eps;
2296+
normal = transform.getRotation() * Vec3f(0, 0, 1); // (1, 0, 0) or (-1, 0, 0)
2297+
SET_LINE;
2298+
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
2299+
2300+
eps = -1e-6;
2301+
tf1 = Transform3f(Vec3f(0, 0, eps));
2302+
tf2 = Transform3f();
2303+
p1 << 0, 0, 5 + eps;
2304+
p2 << 0, 0, 0;
2305+
contact << (p1 + p2) / 2;
2306+
depth = -5 - eps;
2307+
normal << 0, 0, 1; // (1, 0, 0) or (-1, 0, 0)
2308+
SET_LINE;
2309+
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);
2310+
2311+
tf1 = transform * tf1;
2312+
tf2 = transform;
2313+
contact = transform.transform((p1 + p2) / 2);
2314+
depth = -5 - eps;
22562315
normal = transform.getRotation() * Vec3f(0, 0, 1); // (1, 0, 0) or (-1, 0, 0)
22572316
SET_LINE;
22582317
testShapeIntersection(s, tf1, hs, tf2, true, &contact, &depth, &normal, true);

0 commit comments

Comments
 (0)