1 #define BOOST_TEST_MODULE COAL_SIMPLE
2 #include <boost/test/included/unit_test.hpp>
7 #include "fcl_resources/config.h"
23 Project::ProjectResult
res = Project::projectLine(v1, v2, p);
24 BOOST_CHECK(
res.encode == 3);
26 BOOST_CHECK(
approx(
res.parameterization[0], 0.5));
27 BOOST_CHECK(
approx(
res.parameterization[1], 0.5));
30 res = Project::projectLine(v1, v2, p);
31 BOOST_CHECK(
res.encode == 1);
33 BOOST_CHECK(
approx(
res.parameterization[0], 1));
34 BOOST_CHECK(
approx(
res.parameterization[1], 0));
37 res = Project::projectLine(v1, v2, p);
38 BOOST_CHECK(
res.encode == 2);
40 BOOST_CHECK(
approx(
res.parameterization[0], 0));
41 BOOST_CHECK(
approx(
res.parameterization[1], 1));
50 Project::ProjectResult
res = Project::projectTriangle(v1, v2, v3, p);
51 BOOST_CHECK(
res.encode == 7);
52 BOOST_CHECK(
approx(
res.sqr_distance, 4 / 3.0));
53 BOOST_CHECK(
approx(
res.parameterization[0], 1 / 3.0));
54 BOOST_CHECK(
approx(
res.parameterization[1], 1 / 3.0));
55 BOOST_CHECK(
approx(
res.parameterization[2], 1 / 3.0));
58 res = Project::projectTriangle(v1, v2, v3, p);
59 BOOST_CHECK(
res.encode == 1);
60 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
61 BOOST_CHECK(
approx(
res.parameterization[0], 1));
62 BOOST_CHECK(
approx(
res.parameterization[1], 0));
63 BOOST_CHECK(
approx(
res.parameterization[2], 0));
66 res = Project::projectTriangle(v1, v2, v3, p);
67 BOOST_CHECK(
res.encode == 4);
68 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
69 BOOST_CHECK(
approx(
res.parameterization[0], 0));
70 BOOST_CHECK(
approx(
res.parameterization[1], 0));
71 BOOST_CHECK(
approx(
res.parameterization[2], 1));
74 res = Project::projectTriangle(v1, v2, v3, p);
75 BOOST_CHECK(
res.encode == 2);
76 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
77 BOOST_CHECK(
approx(
res.parameterization[0], 0));
78 BOOST_CHECK(
approx(
res.parameterization[1], 1));
79 BOOST_CHECK(
approx(
res.parameterization[2], 0));
82 res = Project::projectTriangle(v1, v2, v3, p);
83 BOOST_CHECK(
res.encode == 6);
84 BOOST_CHECK(
approx(
res.sqr_distance, 0.5));
85 BOOST_CHECK(
approx(
res.parameterization[0], 0));
86 BOOST_CHECK(
approx(
res.parameterization[1], 0.5));
87 BOOST_CHECK(
approx(
res.parameterization[2], 0.5));
90 res = Project::projectTriangle(v1, v2, v3, p);
91 BOOST_CHECK(
res.encode == 5);
92 BOOST_CHECK(
approx(
res.sqr_distance, 0.5));
93 BOOST_CHECK(
approx(
res.parameterization[0], 0.5));
94 BOOST_CHECK(
approx(
res.parameterization[1], 0));
95 BOOST_CHECK(
approx(
res.parameterization[2], 0.5));
98 res = Project::projectTriangle(v1, v2, v3, p);
99 BOOST_CHECK(
res.encode == 3);
100 BOOST_CHECK(
approx(
res.sqr_distance, 0.5));
101 BOOST_CHECK(
approx(
res.parameterization[0], 0.5));
102 BOOST_CHECK(
approx(
res.parameterization[1], 0.5));
103 BOOST_CHECK(
approx(
res.parameterization[2], 0));
112 Vec3s p(0.5, 0.5, 0.5);
113 Project::ProjectResult
res = Project::projectTetrahedra(v1, v2, v3, v4, p);
114 BOOST_CHECK(
res.encode == 15);
115 BOOST_CHECK(
approx(
res.sqr_distance, 0));
116 BOOST_CHECK(
approx(
res.parameterization[0], 0.25));
117 BOOST_CHECK(
approx(
res.parameterization[1], 0.25));
118 BOOST_CHECK(
approx(
res.parameterization[2], 0.25));
119 BOOST_CHECK(
approx(
res.parameterization[3], 0.25));
122 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
123 BOOST_CHECK(
res.encode == 7);
124 BOOST_CHECK(
approx(
res.sqr_distance, 1 / 3.0));
125 BOOST_CHECK(
approx(
res.parameterization[0], 1 / 3.0));
126 BOOST_CHECK(
approx(
res.parameterization[1], 1 / 3.0));
127 BOOST_CHECK(
approx(
res.parameterization[2], 1 / 3.0));
128 BOOST_CHECK(
approx(
res.parameterization[3], 0));
131 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
132 BOOST_CHECK(
res.encode == 11);
133 BOOST_CHECK(
approx(
res.sqr_distance, 1 / 3.0));
134 BOOST_CHECK(
approx(
res.parameterization[0], 1 / 3.0));
135 BOOST_CHECK(
approx(
res.parameterization[1], 1 / 3.0));
136 BOOST_CHECK(
approx(
res.parameterization[2], 0));
137 BOOST_CHECK(
approx(
res.parameterization[3], 1 / 3.0));
140 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
141 BOOST_CHECK(
res.encode == 14);
142 BOOST_CHECK(
approx(
res.sqr_distance, 1 / 3.0));
143 BOOST_CHECK(
approx(
res.parameterization[0], 0));
144 BOOST_CHECK(
approx(
res.parameterization[1], 1 / 3.0));
145 BOOST_CHECK(
approx(
res.parameterization[2], 1 / 3.0));
146 BOOST_CHECK(
approx(
res.parameterization[3], 1 / 3.0));
149 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
150 BOOST_CHECK(
res.encode == 13);
151 BOOST_CHECK(
approx(
res.sqr_distance, 1 / 3.0));
152 BOOST_CHECK(
approx(
res.parameterization[0], 1 / 3.0));
153 BOOST_CHECK(
approx(
res.parameterization[1], 0));
154 BOOST_CHECK(
approx(
res.parameterization[2], 1 / 3.0));
155 BOOST_CHECK(
approx(
res.parameterization[3], 1 / 3.0));
157 p =
Vec3s(1.5, 1.5, 1.5);
158 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
159 BOOST_CHECK(
res.encode == 8);
160 BOOST_CHECK(
approx(
res.sqr_distance, 0.75));
161 BOOST_CHECK(
approx(
res.parameterization[0], 0));
162 BOOST_CHECK(
approx(
res.parameterization[1], 0));
163 BOOST_CHECK(
approx(
res.parameterization[2], 0));
164 BOOST_CHECK(
approx(
res.parameterization[3], 1));
166 p =
Vec3s(1.5, -0.5, -0.5);
167 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
168 BOOST_CHECK(
res.encode == 4);
169 BOOST_CHECK(
approx(
res.sqr_distance, 0.75));
170 BOOST_CHECK(
approx(
res.parameterization[0], 0));
171 BOOST_CHECK(
approx(
res.parameterization[1], 0));
172 BOOST_CHECK(
approx(
res.parameterization[2], 1));
173 BOOST_CHECK(
approx(
res.parameterization[3], 0));
175 p =
Vec3s(-0.5, -0.5, 1.5);
176 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
177 BOOST_CHECK(
res.encode == 1);
178 BOOST_CHECK(
approx(
res.sqr_distance, 0.75));
179 BOOST_CHECK(
approx(
res.parameterization[0], 1));
180 BOOST_CHECK(
approx(
res.parameterization[1], 0));
181 BOOST_CHECK(
approx(
res.parameterization[2], 0));
182 BOOST_CHECK(
approx(
res.parameterization[3], 0));
184 p =
Vec3s(-0.5, 1.5, -0.5);
185 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
186 BOOST_CHECK(
res.encode == 2);
187 BOOST_CHECK(
approx(
res.sqr_distance, 0.75));
188 BOOST_CHECK(
approx(
res.parameterization[0], 0));
189 BOOST_CHECK(
approx(
res.parameterization[1], 1));
190 BOOST_CHECK(
approx(
res.parameterization[2], 0));
191 BOOST_CHECK(
approx(
res.parameterization[3], 0));
193 p =
Vec3s(0.5, -0.5, 0.5);
194 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
195 BOOST_CHECK(
res.encode == 5);
196 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
197 BOOST_CHECK(
approx(
res.parameterization[0], 0.5));
198 BOOST_CHECK(
approx(
res.parameterization[1], 0));
199 BOOST_CHECK(
approx(
res.parameterization[2], 0.5));
200 BOOST_CHECK(
approx(
res.parameterization[3], 0));
202 p =
Vec3s(0.5, 1.5, 0.5);
203 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
204 BOOST_CHECK(
res.encode == 10);
205 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
206 BOOST_CHECK(
approx(
res.parameterization[0], 0));
207 BOOST_CHECK(
approx(
res.parameterization[1], 0.5));
208 BOOST_CHECK(
approx(
res.parameterization[2], 0));
209 BOOST_CHECK(
approx(
res.parameterization[3], 0.5));
211 p =
Vec3s(1.5, 0.5, 0.5);
212 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
213 BOOST_CHECK(
res.encode == 12);
214 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
215 BOOST_CHECK(
approx(
res.parameterization[0], 0));
216 BOOST_CHECK(
approx(
res.parameterization[1], 0));
217 BOOST_CHECK(
approx(
res.parameterization[2], 0.5));
218 BOOST_CHECK(
approx(
res.parameterization[3], 0.5));
220 p =
Vec3s(-0.5, 0.5, 0.5);
221 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
222 BOOST_CHECK(
res.encode == 3);
223 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
224 BOOST_CHECK(
approx(
res.parameterization[0], 0.5));
225 BOOST_CHECK(
approx(
res.parameterization[1], 0.5));
226 BOOST_CHECK(
approx(
res.parameterization[2], 0));
227 BOOST_CHECK(
approx(
res.parameterization[3], 0));
229 p =
Vec3s(0.5, 0.5, 1.5);
230 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
231 BOOST_CHECK(
res.encode == 9);
232 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
233 BOOST_CHECK(
approx(
res.parameterization[0], 0.5));
234 BOOST_CHECK(
approx(
res.parameterization[1], 0));
235 BOOST_CHECK(
approx(
res.parameterization[2], 0));
236 BOOST_CHECK(
approx(
res.parameterization[3], 0.5));
238 p =
Vec3s(0.5, 0.5, -0.5);
239 res = Project::projectTetrahedra(v1, v2, v3, v4, p);
240 BOOST_CHECK(
res.encode == 6);
241 BOOST_CHECK(
approx(
res.sqr_distance, 0.25));
242 BOOST_CHECK(
approx(
res.parameterization[0], 0));
243 BOOST_CHECK(
approx(
res.parameterization[1], 0.5));
244 BOOST_CHECK(
approx(
res.parameterization[2], 0.5));
245 BOOST_CHECK(
approx(
res.parameterization[3], 0));