5 #define BOOST_TEST_MODULE matrix_homogeneous
7 #include <boost/math/constants/constants.hpp>
8 #include <boost/test/tools/floating_point_comparison.hpp>
9 #include <boost/test/tools/output_test_stream.hpp>
10 #include <boost/test/unit_test.hpp>
13 using boost::math::constants::pi;
14 using boost::test_tools::output_test_stream;
18 #define MATRIX_BOOST_REQUIRE_CLOSE(N, M, LEFT, RIGHT, TOLERANCE) \
19 for (unsigned i = 0; i < N; ++i) \
20 for (unsigned j = 0; j < M; ++j) \
21 BOOST_REQUIRE_CLOSE(LEFT(i, j), RIGHT(i, j), TOLERANCE)
23 #define MATRIX_4x4_BOOST_REQUIRE_CLOSE(LEFT, RIGHT, TOLERANCE) \
24 MATRIX_BOOST_REQUIRE_CLOSE(4, 4, LEFT, RIGHT, TOLERANCE)
26 #define MATRIX_IDENTITY_4x4_REQUIRE_CLOSE(M, TOLERANCE) \
27 for (unsigned i = 0; i < 4; ++i) \
28 for (unsigned j = 0; j < 4; ++j) \
30 BOOST_REQUIRE_CLOSE(M(i, j), 1., TOLERANCE); \
32 BOOST_CHECK_SMALL(M(i, j), .01 * TOLERANCE)
34 #define MATRIX_HOMO_INIT(M, tx, ty, tz, roll, pitch, yaw) \
35 M(0, 0) = cos(pitch) * cos(yaw); \
36 M(0, 1) = sin(roll) * sin(pitch) * cos(yaw) - cos(roll) * sin(yaw); \
37 M(0, 2) = cos(roll) * sin(pitch) * cos(yaw) + sin(roll) * sin(yaw); \
39 M(1, 0) = cos(pitch) * sin(yaw); \
40 M(1, 1) = sin(roll) * sin(pitch) * sin(yaw) + cos(roll) * cos(yaw); \
41 M(1, 2) = cos(roll) * sin(pitch) * sin(yaw) - sin(roll) * cos(yaw); \
43 M(2, 0) = -sin(pitch); \
44 M(2, 1) = sin(roll) * cos(pitch); \
45 M(2, 2) = cos(roll) * cos(pitch); \
53 for (
unsigned int i = 0;
i < 1000;
i++) {
55 double roll, pitch, yaw;
57 tx = (10. *
rand()) / RAND_MAX - 5.;
58 ty = (10. *
rand()) / RAND_MAX - 5.;
59 tz = (10. *
rand()) / RAND_MAX - 5.;
60 roll = (pi<double>() *
rand()) / RAND_MAX - .5 * pi<double>();
61 pitch = (pi<double>() *
rand()) / RAND_MAX - .5 * pi<double>();
62 yaw = (2 * pi<double>() *
rand()) / RAND_MAX - pi<double>();
66 tx = (10. *
rand()) / RAND_MAX;
67 ty = (10. *
rand()) / RAND_MAX - 5.;
68 tz = (10. *
rand()) / RAND_MAX - 5.;
69 roll = (pi<double>() *
rand()) / RAND_MAX - .5 * pi<double>();
70 pitch = (pi<double>() *
rand()) / RAND_MAX - .5 * pi<double>();
71 yaw = (2 * pi<double>() *
rand()) / RAND_MAX - pi<double>();
83 for (
unsigned int i = 0;
i < 1000;
i++) {
85 double roll, pitch, yaw;
87 tx = (10. *
rand()) / RAND_MAX - 5.;
88 ty = (10. *
rand()) / RAND_MAX - 5.;
89 tz = (10. *
rand()) / RAND_MAX - 5.;
90 roll = (pi<double>() *
rand()) / RAND_MAX - .5 * pi<double>();
91 pitch = (pi<double>() *
rand()) / RAND_MAX - .5 * pi<double>();
92 yaw = (2 * pi<double>() *
rand()) / RAND_MAX - pi<double>();
95 tx = (10. *
rand()) / RAND_MAX;
96 ty = (10. *
rand()) / RAND_MAX - 5.;
97 tz = (10. *
rand()) / RAND_MAX - 5.;
98 roll = (pi<double>() *
rand()) / RAND_MAX - .5 * pi<double>();
99 pitch = (pi<double>() *
rand()) / RAND_MAX - .5 * pi<double>();
100 yaw = (2 * pi<double>() *
rand()) / RAND_MAX - pi<double>();
104 invH1 = H1.inverse();
105 invH2 = H2.inverse();
106 invH3 = H3.inverse();