15 #include <gtest/gtest.h> 22 #include <geometry_msgs/Point.h> 27 TEST(Torres16Test, CalcSweepDirectionTest)
29 std::vector<geometry_msgs::Point> polygon;
32 geometry_msgs::Point p1, p2, p3, p4, p5;
35 std::array<geometry_msgs::Point, 2> e1, e2, e3, e4, e5;
48 polygon.push_back(p1);
49 polygon.push_back(p2);
50 polygon.push_back(p3);
61 EXPECT_DOUBLE_EQ(e2.front().x, dir.base_edge.front().x);
62 EXPECT_DOUBLE_EQ(e2.front().y, dir.base_edge.front().y);
63 EXPECT_DOUBLE_EQ(e2.back().x, dir.base_edge.back().x);
64 EXPECT_DOUBLE_EQ(e2.back().y, dir.base_edge.back().y);
65 EXPECT_DOUBLE_EQ(p1.x, dir.opposed_vertex.x);
66 EXPECT_DOUBLE_EQ(p1.y, dir.opposed_vertex.y);
84 polygon.push_back(p1);
85 polygon.push_back(p2);
86 polygon.push_back(p3);
87 polygon.push_back(p4);
98 dir = sweepDirection(polygon);
100 EXPECT_DOUBLE_EQ(e2.front().x, dir.base_edge.front().x);
101 EXPECT_DOUBLE_EQ(e2.front().y, dir.base_edge.front().y);
102 EXPECT_DOUBLE_EQ(e2.back().x, dir.base_edge.back().x);
103 EXPECT_DOUBLE_EQ(e2.back().y, dir.base_edge.back().y);
104 EXPECT_DOUBLE_EQ(p1.x, dir.opposed_vertex.x);
105 EXPECT_DOUBLE_EQ(p1.y, dir.opposed_vertex.y);
126 polygon.push_back(p1);
127 polygon.push_back(p2);
128 polygon.push_back(p3);
129 polygon.push_back(p4);
130 polygon.push_back(p5);
143 dir = sweepDirection(polygon);
145 EXPECT_DOUBLE_EQ(e4.front().x, dir.base_edge.front().x);
146 EXPECT_DOUBLE_EQ(e4.front().y, dir.base_edge.front().y);
147 EXPECT_DOUBLE_EQ(e4.back().x, dir.base_edge.back().x);
148 EXPECT_DOUBLE_EQ(e4.back().y, dir.base_edge.back().y);
149 EXPECT_DOUBLE_EQ(p2.x, dir.opposed_vertex.x);
150 EXPECT_DOUBLE_EQ(p2.y, dir.opposed_vertex.y);
155 int main(
int argc,
char** argv)
157 ::testing::InitGoogleTest(&argc, argv);
158 return RUN_ALL_TESTS();
Utility for computational geometry.
TEST(Torres16Test, CalcSweepDirectionTest)
Test for sweepDirection()
int main(int argc, char **argv)
Storage for line sweep direction.