11 #include <CTraitsTest.h> 12 #include <gtest/gtest.h> 18 template class mrpt::CTraitsTest<mrpt::math::TPoint2D>;
19 template class mrpt::CTraitsTest<mrpt::math::TPoint3D>;
20 template class mrpt::CTraitsTest<mrpt::math::TPoint3Df>;
21 template class mrpt::CTraitsTest<mrpt::math::TPose2D>;
22 template class mrpt::CTraitsTest<mrpt::math::TPose3D>;
23 template class mrpt::CTraitsTest<mrpt::math::TPose3DQuat>;
25 TEST(LightGeomData, PragmaPack)
29 EXPECT_TRUE(&
p.x == &(
p[0]));
30 EXPECT_TRUE(&
p.y == &(
p[1]));
34 EXPECT_TRUE(&
p.x == &(
p[0]));
35 EXPECT_TRUE(&
p.y == &(
p[1]));
36 EXPECT_TRUE(&
p.z == &(
p[2]));
40 EXPECT_TRUE(&
p.x == &(
p[0]));
41 EXPECT_TRUE(&
p.y == &(
p[1]));
42 EXPECT_TRUE(&
p.phi == &(
p[2]));
46 EXPECT_TRUE(&
p.x == &(
p[0]));
47 EXPECT_TRUE(&
p.y == &(
p[1]));
48 EXPECT_TRUE(&
p.z == &(
p[2]));
49 EXPECT_TRUE(&
p.yaw == &(
p[3]));
50 EXPECT_TRUE(&
p.pitch == &(
p[4]));
51 EXPECT_TRUE(&
p.roll == &(
p[5]));
55 EXPECT_TRUE(&
s.point1 == &(
s[0]));
56 EXPECT_TRUE(&
s.point2 == &(
s[1]));
60 TEST(LightGeomData, ExpectedMemorySizes)
62 EXPECT_EQ(
sizeof(
TPoint2D), 2 *
sizeof(
double));
63 EXPECT_EQ(
sizeof(
TPoint3D), 3 *
sizeof(
double));
64 EXPECT_EQ(
sizeof(
TPoint3Df), 3 *
sizeof(
float));
65 EXPECT_EQ(
sizeof(
TPose2D), 3 *
sizeof(
double));
66 EXPECT_EQ(
sizeof(
TPose3D), 6 *
sizeof(
double));
70 TEST(LightGeomData, ConstExprCtors)
79 static_assert(
p.x == 1.0,
"p.x == 1.0");
80 static_assert(
p.y == 2.0,
"p.y == 2.0");
81 static_assert(
p[0] == 1.0,
"p[0] == 1.0");
82 static_assert(
p[1] == 2.0,
"p[1] == 2.0");
86 static_assert(
p.x == 1.0,
"p.x == 1.0");
87 static_assert(
p.y == 2.0,
"p.y == 2.0");
88 static_assert(
p.z == 3.0,
"p.z == 3.0");
89 static_assert(
p[0] == 1.0,
"p[0] == 1.0");
90 static_assert(
p[1] == 2.0,
"p[1] == 2.0");
91 static_assert(
p[2] == 3.0,
"p[2] == 3.0");
94 constexpr
TPose3D p(1.0, 2.0, 3.0, 0.1, 0.2, 0.3);
95 static_assert(
p.x == 1.0,
"p.x == 1.0");
96 static_assert(
p.y == 2.0,
"p.y == 2.0");
97 static_assert(
p.z == 3.0,
"p.z == 3.0");
107 static_assert(p_add.x == 6.0,
"p_add.x == 6.0");
108 static_assert(p_add.y == 8.0,
"p_add.y == 8.0");
110 static_assert(p_sub.x == 2.0,
"p_sub.x == 2.0");
111 static_assert(p_sub.y == 4.0,
"p_sub.y == 4.0");
113 static_assert(p_mul.x == 8.0,
"p_mul.x == 8.0");
114 static_assert(p_mul.y == 12.0,
"p_mul.y == 12.0");
116 static_assert(p_div.x == 2.0,
"p_div.x == 2.0");
117 static_assert(p_div.y == 3.0,
"p_div.y == 3.0");
121 TEST(LightGeomData, Conversions)
124 TPose3D p1{1.0,2.0,3.0,4.0,5.0,6.0};
132 EXPECT_EQ(p2.
x, 1.0);
133 EXPECT_EQ(p2.
y, 2.0);
134 EXPECT_EQ(p2.
phi, 0.0);
138 TEST(LightGeomData, Comparisons)
143 EXPECT_FALSE(p1 < p2);
148 EXPECT_TRUE(p1 < p2);
149 EXPECT_FALSE(p2 < p1);
160 EXPECT_EQ(
s,
"[1.000000 2.000000 180.000000]");
164 p.fromString(
"[1 2 180]");
165 EXPECT_DOUBLE_EQ(
p.x, 1);
166 EXPECT_DOUBLE_EQ(
p.y, 2);
167 EXPECT_DOUBLE_EQ(
p.phi,
M_PI);
This base provides a set of functions for maths stuff.
2D segment, consisting of two points.
Lightweight 3D point (float version).
TEST(LightGeomData, PragmaPack)
GLsizei const GLchar ** string
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
double phi
Orientation (rads)