37 #define _USE_MATH_DEFINES
40 #define BOOST_TEST_MODULE COAL_BOX_BOX
41 #include <boost/test/included/unit_test.hpp>
43 #define CHECK_CLOSE_TO_0(x, eps) BOOST_CHECK_CLOSE((x + 1.0), (1.0), (eps))
78 std::cerr <<
"Applied transformations on two boxes" << std::endl;
79 std::cerr <<
" T1 = " <<
tf1.getTranslation() << std::endl
80 <<
" R1 = " <<
tf1.getRotation() << std::endl
81 <<
" T2 = " <<
tf2.getTranslation() << std::endl
82 <<
" R2 = " <<
tf2.getRotation() << std::endl;
83 std::cerr <<
"Closest points: p1 = " << distanceResult.
nearest_points[0]
85 <<
", distance = " << distanceResult.
min_distance << std::endl;
86 double dx = 25 - 3 - 1;
87 double dy = 20 - 5 - 1;
88 double dz = 5 - 1 - 1;
93 sqrt(dx * dx + dy * dy + dz * dz), 1e-4);
95 BOOST_CHECK_CLOSE(
p1[0], 3, 1e-6);
96 BOOST_CHECK_CLOSE(
p1[1], 5, 1e-6);
97 BOOST_CHECK_CLOSE(
p1[2], 1, 1e-6);
98 BOOST_CHECK_CLOSE(p2[0], 24, 1e-6);
99 BOOST_CHECK_CLOSE(p2[1], 19, 1e-6);
100 BOOST_CHECK_CLOSE(p2[2], 4, 1e-6);
106 static double pi = M_PI;
109 sin(
pi / 8) / sqrt(3), sin(
pi / 8) / sqrt(3)),
121 std::cerr <<
"Applied transformations on two boxes" << std::endl;
122 std::cerr <<
" T1 = " <<
tf1.getTranslation() << std::endl
123 <<
" R1 = " <<
tf1.getRotation() << std::endl
124 <<
" T2 = " <<
tf2.getTranslation() << std::endl
125 <<
" R2 = " <<
tf2.getRotation() << std::endl;
126 std::cerr <<
"Closest points: p1 = " << distanceResult.
nearest_points[0]
128 <<
", distance = " << distanceResult.
min_distance << std::endl;
132 double distance = -1.62123444 + 10 - 1;
135 BOOST_CHECK_CLOSE(
p1[0], 0.60947571, 1e-4);
136 BOOST_CHECK_CLOSE(
p1[1], 0.01175873, 1e-4);
137 BOOST_CHECK_CLOSE(
p1[2], 1, 1e-6);
138 BOOST_CHECK_CLOSE(p2[0], 0.60947571, 1e-4);
139 BOOST_CHECK_CLOSE(p2[1], 0.01175873, 1e-4);
140 BOOST_CHECK_CLOSE(p2[2], -1.62123444 + 10, 1e-4);
146 static double pi = M_PI;
161 std::cerr <<
"Applied transformations on two boxes" << std::endl;
162 std::cerr <<
" T1 = " <<
tf1.getTranslation() << std::endl
163 <<
" R1 = " <<
tf1.getRotation() << std::endl
164 <<
" T2 = " <<
tf2.getTranslation() << std::endl
165 <<
" R2 = " <<
tf2.getRotation() << std::endl;
166 std::cerr <<
"Closest points: p1 = " << distanceResult.
nearest_points[0]
168 <<
", distance = " << distanceResult.
min_distance << std::endl;
175 const Vec3s p1Ref(sqrt(2) / 2 - 2, 1, .5);
176 const Vec3s p2Ref(2 - sqrt(2) / 2, 1, .5);
177 BOOST_CHECK_CLOSE(
p1[0], p1Ref[0], 1e-4);
178 BOOST_CHECK_CLOSE(
p1[1], p1Ref[1], 1e-4);
179 BOOST_CHECK_CLOSE(
p1[2], p1Ref[2], 1e-4);
180 BOOST_CHECK_CLOSE(p2[0], p2Ref[0], 1e-4);
181 BOOST_CHECK_CLOSE(p2[1], p2Ref[1], 1e-4);
182 BOOST_CHECK_CLOSE(p2[2], p2Ref[2], 1e-4);
186 0.310622451066, 0.444435113443),
193 distanceResult.
clear();
196 std::cerr <<
"Applied transformations on two boxes" << std::endl;
197 std::cerr <<
" T1 = " <<
tf1.getTranslation() << std::endl
198 <<
" R1 = " <<
tf1.getRotation() << std::endl
199 <<
" T2 = " <<
tf2.getTranslation() << std::endl
200 <<
" R2 = " <<
tf2.getRotation() << std::endl;
201 std::cerr <<
"Closest points: p1 = " << distanceResult.
nearest_points[0]
203 <<
", distance = " << distanceResult.
min_distance << std::endl;
209 BOOST_CHECK_CLOSE(
p1[0], p1Moved[0], 1e-4);
210 BOOST_CHECK_CLOSE(
p1[1], p1Moved[1], 1e-4);
211 BOOST_CHECK_CLOSE(
p1[2], p1Moved[2], 1e-4);
212 BOOST_CHECK_CLOSE(p2[0], p2Moved[0], 1e-4);
213 BOOST_CHECK_CLOSE(p2[1], p2Moved[1], 1e-4);
214 BOOST_CHECK_CLOSE(p2[2], p2Moved[2], 1e-4);
233 tf1.setTranslation(
Vec3s(1.01, 0, 0));
234 distanceResult.
clear();
240 tf1.setTranslation(
Vec3s(0.99, 0, 0));
241 distanceResult.
clear();
248 distanceResult.
clear();