1 #define BOOST_TEST_MODULE FCL_SIMPLE 2 #include <boost/test/included/unit_test.hpp> 7 #include "fcl_resources/config.h" 21 Project::ProjectResult
res = Project::projectLine(v1, v2, p);
22 BOOST_CHECK(res.encode == 3);
23 BOOST_CHECK(
approx(res.sqr_distance, 0));
24 BOOST_CHECK(
approx(res.parameterization[0], 0.5));
25 BOOST_CHECK(
approx(res.parameterization[1], 0.5));
28 res = Project::projectLine(v1, v2, p);
29 BOOST_CHECK(res.encode == 1);
30 BOOST_CHECK(
approx(res.sqr_distance, 1));
31 BOOST_CHECK(
approx(res.parameterization[0], 1));
32 BOOST_CHECK(
approx(res.parameterization[1], 0));
35 res = Project::projectLine(v1, v2, p);
36 BOOST_CHECK(res.encode == 2);
37 BOOST_CHECK(
approx(res.sqr_distance, 1));
38 BOOST_CHECK(
approx(res.parameterization[0], 0));
39 BOOST_CHECK(
approx(res.parameterization[1], 1));
48 Project::ProjectResult
res = Project::projectTriangle(v1, v2, v3, p);
49 BOOST_CHECK(res.encode == 7);
50 BOOST_CHECK(
approx(res.sqr_distance, 4 / 3.0));
51 BOOST_CHECK(
approx(res.parameterization[0], 1 / 3.0));
52 BOOST_CHECK(
approx(res.parameterization[1], 1 / 3.0));
53 BOOST_CHECK(
approx(res.parameterization[2], 1 / 3.0));
56 res = Project::projectTriangle(v1, v2, v3, p);
57 BOOST_CHECK(res.encode == 1);
58 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
59 BOOST_CHECK(
approx(res.parameterization[0], 1));
60 BOOST_CHECK(
approx(res.parameterization[1], 0));
61 BOOST_CHECK(
approx(res.parameterization[2], 0));
64 res = Project::projectTriangle(v1, v2, v3, p);
65 BOOST_CHECK(res.encode == 4);
66 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
67 BOOST_CHECK(
approx(res.parameterization[0], 0));
68 BOOST_CHECK(
approx(res.parameterization[1], 0));
69 BOOST_CHECK(
approx(res.parameterization[2], 1));
72 res = Project::projectTriangle(v1, v2, v3, p);
73 BOOST_CHECK(res.encode == 2);
74 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
75 BOOST_CHECK(
approx(res.parameterization[0], 0));
76 BOOST_CHECK(
approx(res.parameterization[1], 1));
77 BOOST_CHECK(
approx(res.parameterization[2], 0));
80 res = Project::projectTriangle(v1, v2, v3, p);
81 BOOST_CHECK(res.encode == 6);
82 BOOST_CHECK(
approx(res.sqr_distance, 0.5));
83 BOOST_CHECK(
approx(res.parameterization[0], 0));
84 BOOST_CHECK(
approx(res.parameterization[1], 0.5));
85 BOOST_CHECK(
approx(res.parameterization[2], 0.5));
88 res = Project::projectTriangle(v1, v2, v3, p);
89 BOOST_CHECK(res.encode == 5);
90 BOOST_CHECK(
approx(res.sqr_distance, 0.5));
91 BOOST_CHECK(
approx(res.parameterization[0], 0.5));
92 BOOST_CHECK(
approx(res.parameterization[1], 0));
93 BOOST_CHECK(
approx(res.parameterization[2], 0.5));
96 res = Project::projectTriangle(v1, v2, v3, p);
97 BOOST_CHECK(res.encode == 3);
98 BOOST_CHECK(
approx(res.sqr_distance, 0.5));
99 BOOST_CHECK(
approx(res.parameterization[0], 0.5));
100 BOOST_CHECK(
approx(res.parameterization[1], 0.5));
101 BOOST_CHECK(
approx(res.parameterization[2], 0));
110 Vec3f p(0.5, 0.5, 0.5);
111 Project::ProjectResult
res = Project::projectTetrahedra(v1, v2, v3, v4, p);
112 BOOST_CHECK(res.encode == 15);
113 BOOST_CHECK(
approx(res.sqr_distance, 0));
114 BOOST_CHECK(
approx(res.parameterization[0], 0.25));
115 BOOST_CHECK(
approx(res.parameterization[1], 0.25));
116 BOOST_CHECK(
approx(res.parameterization[2], 0.25));
117 BOOST_CHECK(
approx(res.parameterization[3], 0.25));
120 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
121 BOOST_CHECK(res.encode == 7);
122 BOOST_CHECK(
approx(res.sqr_distance, 1 / 3.0));
123 BOOST_CHECK(
approx(res.parameterization[0], 1 / 3.0));
124 BOOST_CHECK(
approx(res.parameterization[1], 1 / 3.0));
125 BOOST_CHECK(
approx(res.parameterization[2], 1 / 3.0));
126 BOOST_CHECK(
approx(res.parameterization[3], 0));
129 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
130 BOOST_CHECK(res.encode == 11);
131 BOOST_CHECK(
approx(res.sqr_distance, 1 / 3.0));
132 BOOST_CHECK(
approx(res.parameterization[0], 1 / 3.0));
133 BOOST_CHECK(
approx(res.parameterization[1], 1 / 3.0));
134 BOOST_CHECK(
approx(res.parameterization[2], 0));
135 BOOST_CHECK(
approx(res.parameterization[3], 1 / 3.0));
138 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
139 BOOST_CHECK(res.encode == 14);
140 BOOST_CHECK(
approx(res.sqr_distance, 1 / 3.0));
141 BOOST_CHECK(
approx(res.parameterization[0], 0));
142 BOOST_CHECK(
approx(res.parameterization[1], 1 / 3.0));
143 BOOST_CHECK(
approx(res.parameterization[2], 1 / 3.0));
144 BOOST_CHECK(
approx(res.parameterization[3], 1 / 3.0));
147 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
148 BOOST_CHECK(res.encode == 13);
149 BOOST_CHECK(
approx(res.sqr_distance, 1 / 3.0));
150 BOOST_CHECK(
approx(res.parameterization[0], 1 / 3.0));
151 BOOST_CHECK(
approx(res.parameterization[1], 0));
152 BOOST_CHECK(
approx(res.parameterization[2], 1 / 3.0));
153 BOOST_CHECK(
approx(res.parameterization[3], 1 / 3.0));
155 p =
Vec3f(1.5, 1.5, 1.5);
156 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
157 BOOST_CHECK(res.encode == 8);
158 BOOST_CHECK(
approx(res.sqr_distance, 0.75));
159 BOOST_CHECK(
approx(res.parameterization[0], 0));
160 BOOST_CHECK(
approx(res.parameterization[1], 0));
161 BOOST_CHECK(
approx(res.parameterization[2], 0));
162 BOOST_CHECK(
approx(res.parameterization[3], 1));
164 p =
Vec3f(1.5, -0.5, -0.5);
165 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
166 BOOST_CHECK(res.encode == 4);
167 BOOST_CHECK(
approx(res.sqr_distance, 0.75));
168 BOOST_CHECK(
approx(res.parameterization[0], 0));
169 BOOST_CHECK(
approx(res.parameterization[1], 0));
170 BOOST_CHECK(
approx(res.parameterization[2], 1));
171 BOOST_CHECK(
approx(res.parameterization[3], 0));
173 p =
Vec3f(-0.5, -0.5, 1.5);
174 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
175 BOOST_CHECK(res.encode == 1);
176 BOOST_CHECK(
approx(res.sqr_distance, 0.75));
177 BOOST_CHECK(
approx(res.parameterization[0], 1));
178 BOOST_CHECK(
approx(res.parameterization[1], 0));
179 BOOST_CHECK(
approx(res.parameterization[2], 0));
180 BOOST_CHECK(
approx(res.parameterization[3], 0));
182 p =
Vec3f(-0.5, 1.5, -0.5);
183 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
184 BOOST_CHECK(res.encode == 2);
185 BOOST_CHECK(
approx(res.sqr_distance, 0.75));
186 BOOST_CHECK(
approx(res.parameterization[0], 0));
187 BOOST_CHECK(
approx(res.parameterization[1], 1));
188 BOOST_CHECK(
approx(res.parameterization[2], 0));
189 BOOST_CHECK(
approx(res.parameterization[3], 0));
191 p =
Vec3f(0.5, -0.5, 0.5);
192 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
193 BOOST_CHECK(res.encode == 5);
194 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
195 BOOST_CHECK(
approx(res.parameterization[0], 0.5));
196 BOOST_CHECK(
approx(res.parameterization[1], 0));
197 BOOST_CHECK(
approx(res.parameterization[2], 0.5));
198 BOOST_CHECK(
approx(res.parameterization[3], 0));
200 p =
Vec3f(0.5, 1.5, 0.5);
201 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
202 BOOST_CHECK(res.encode == 10);
203 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
204 BOOST_CHECK(
approx(res.parameterization[0], 0));
205 BOOST_CHECK(
approx(res.parameterization[1], 0.5));
206 BOOST_CHECK(
approx(res.parameterization[2], 0));
207 BOOST_CHECK(
approx(res.parameterization[3], 0.5));
209 p =
Vec3f(1.5, 0.5, 0.5);
210 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
211 BOOST_CHECK(res.encode == 12);
212 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
213 BOOST_CHECK(
approx(res.parameterization[0], 0));
214 BOOST_CHECK(
approx(res.parameterization[1], 0));
215 BOOST_CHECK(
approx(res.parameterization[2], 0.5));
216 BOOST_CHECK(
approx(res.parameterization[3], 0.5));
218 p =
Vec3f(-0.5, 0.5, 0.5);
219 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
220 BOOST_CHECK(res.encode == 3);
221 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
222 BOOST_CHECK(
approx(res.parameterization[0], 0.5));
223 BOOST_CHECK(
approx(res.parameterization[1], 0.5));
224 BOOST_CHECK(
approx(res.parameterization[2], 0));
225 BOOST_CHECK(
approx(res.parameterization[3], 0));
227 p =
Vec3f(0.5, 0.5, 1.5);
228 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
229 BOOST_CHECK(res.encode == 9);
230 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
231 BOOST_CHECK(
approx(res.parameterization[0], 0.5));
232 BOOST_CHECK(
approx(res.parameterization[1], 0));
233 BOOST_CHECK(
approx(res.parameterization[2], 0));
234 BOOST_CHECK(
approx(res.parameterization[3], 0.5));
236 p =
Vec3f(0.5, 0.5, -0.5);
237 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
238 BOOST_CHECK(res.encode == 6);
239 BOOST_CHECK(
approx(res.sqr_distance, 0.25));
240 BOOST_CHECK(
approx(res.parameterization[0], 0));
241 BOOST_CHECK(
approx(res.parameterization[1], 0.5));
242 BOOST_CHECK(
approx(res.parameterization[2], 0.5));
243 BOOST_CHECK(
approx(res.parameterization[3], 0));
static bool approx(FCL_REAL x, FCL_REAL y)
BOOST_AUTO_TEST_CASE(projection_test_line)
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f