30 #include <gtest/gtest.h> 34 TEST(IntersectionTests, Intersects)
44 EXPECT_FLOAT_EQ(5.0, c[0]);
45 EXPECT_FLOAT_EQ(5.0, c[1]);
54 EXPECT_FLOAT_EQ(5.0, c[0]);
55 EXPECT_FLOAT_EQ(6.0, c[1]);
64 EXPECT_FLOAT_EQ(5.0, c[0]);
65 EXPECT_FLOAT_EQ(6.0, c[1]);
74 EXPECT_FLOAT_EQ(5.0, c[0]);
75 EXPECT_FLOAT_EQ(6.0, c[1]);
84 EXPECT_FLOAT_EQ(5.0, c[0]);
85 EXPECT_FLOAT_EQ(5.0, c[1]);
94 EXPECT_FLOAT_EQ(-5.0, c[0]);
95 EXPECT_FLOAT_EQ(-5.0, c[1]);
104 EXPECT_FLOAT_EQ(5.0, c[0]);
105 EXPECT_FLOAT_EQ(5.0, c[1]);
108 TEST(IntersectionTests, Parallel)
140 TEST(IntersectionTests, SegmentsIntersect)
150 EXPECT_FLOAT_EQ(5.0, c[0]);
151 EXPECT_FLOAT_EQ(5.0, c[1]);
160 EXPECT_FLOAT_EQ(5.0, c[0]);
161 EXPECT_FLOAT_EQ(6.0, c[1]);
170 EXPECT_FLOAT_EQ(5.0, c[0]);
171 EXPECT_FLOAT_EQ(6.0, c[1]);
180 EXPECT_FLOAT_EQ(5.0, c[0]);
181 EXPECT_FLOAT_EQ(6.0, c[1]);
190 EXPECT_FLOAT_EQ(5.0, c[0]);
191 EXPECT_FLOAT_EQ(5.0, c[1]);
200 EXPECT_FLOAT_EQ(-5.0, c[0]);
201 EXPECT_FLOAT_EQ(-5.0, c[1]);
211 EXPECT_FLOAT_EQ(1.0, c[0]);
212 EXPECT_FLOAT_EQ(1.0, c[1]);
221 EXPECT_FLOAT_EQ(2.0, c[0]);
222 EXPECT_FLOAT_EQ(0.0, c[1]);
230 EXPECT_FLOAT_EQ(2.0, c[0]);
231 EXPECT_FLOAT_EQ(0.0, c[1]);
239 EXPECT_FLOAT_EQ(2.0, c[0]);
240 EXPECT_FLOAT_EQ(0.0, c[1]);
248 EXPECT_FLOAT_EQ(2.0, c[0]);
249 EXPECT_FLOAT_EQ(0.0, c[1]);
257 EXPECT_FLOAT_EQ(2.0, c[0]);
258 EXPECT_FLOAT_EQ(0.0, c[1]);
267 EXPECT_FLOAT_EQ(0.0, c[0]);
268 EXPECT_FLOAT_EQ(2.0, c[1]);
277 EXPECT_FLOAT_EQ(1.0, c[0]);
278 EXPECT_FLOAT_EQ(1.0, c[1]);
286 EXPECT_FLOAT_EQ(33.3, c[0]);
287 EXPECT_FLOAT_EQ(0.0, c[1]);
295 EXPECT_FLOAT_EQ(0.0, c[0]);
296 EXPECT_FLOAT_EQ(0.0, c[1]);
304 EXPECT_FLOAT_EQ(1.0, c[0]);
305 EXPECT_FLOAT_EQ(1.0, c[1]);
313 EXPECT_FLOAT_EQ(1.0, c[0]);
314 EXPECT_FLOAT_EQ(1.0, c[1]);
317 cv::Vec2d(1065.8687582537791058712173253,-1053.2999883795632740657310933),
318 cv::Vec2d(1065.5686875431010776082985103,-1051.8000590902413478033849970),
319 cv::Vec2d(1066.1686875431009866588283330,-1053.0000590902413932781200856),
320 cv::Vec2d(1065.5686875431010776082985103,-1051.8000590902413478033849970),
322 EXPECT_FLOAT_EQ(1065.5686875431010776082985103, c[0]);
323 EXPECT_FLOAT_EQ(-1051.8000590902413478033849970, c[1]);
326 TEST(IntersectionTests, SegmentsDontIntersect)
353 cv::Vec2d(0.999, 0.999),
360 cv::Vec2d(33.3, 0.0000001),
365 cv::Vec2d(1.00001, 1.00001),
366 cv::Vec2d(1.00001, 1.00001),
374 cv::Vec2d(1.00001, 1.00001),
375 cv::Vec2d(1.00001, 1.00001),
379 TEST(IntersectionTests, ParallelSegments)
388 EXPECT_FLOAT_EQ(0.0, c[0]);
389 EXPECT_FLOAT_EQ(0.0, c[1]);
397 EXPECT_FLOAT_EQ(0.0, c[0]);
398 EXPECT_FLOAT_EQ(0.0, c[1]);
406 EXPECT_FLOAT_EQ(10.0, c[0]);
407 EXPECT_FLOAT_EQ(0.0, c[1]);
415 EXPECT_FLOAT_EQ(10.0, c[0]);
416 EXPECT_FLOAT_EQ(0.0, c[1]);
424 EXPECT_FLOAT_EQ(10.0, c[0]);
425 EXPECT_FLOAT_EQ(0.0, c[1]);
433 EXPECT_FLOAT_EQ(10.0, c[0]);
434 EXPECT_FLOAT_EQ(0.0, c[1]);
442 EXPECT_FLOAT_EQ(10.0, c[0]);
443 EXPECT_FLOAT_EQ(0.0, c[1]);
451 EXPECT_FLOAT_EQ(5.0, c[0]);
452 EXPECT_FLOAT_EQ(0.0, c[1]);
460 EXPECT_FLOAT_EQ(5.0, c[0]);
461 EXPECT_FLOAT_EQ(0.0, c[1]);
469 EXPECT_FLOAT_EQ(5.0, c[0]);
470 EXPECT_FLOAT_EQ(0.0, c[1]);
478 EXPECT_FLOAT_EQ(5.0, c[0]);
479 EXPECT_FLOAT_EQ(0.0, c[1]);
487 EXPECT_FLOAT_EQ(6.0, c[0]);
488 EXPECT_FLOAT_EQ(0.0, c[1]);
496 EXPECT_FLOAT_EQ(6.0, c[0]);
497 EXPECT_FLOAT_EQ(0.0, c[1]);
509 cv::Vec2d(0, .00001),
510 cv::Vec2d(10, .00001),
523 cv::Vec2d(10.00001, 0),
529 int main(
int argc,
char **argv)
531 testing::InitGoogleTest(&argc, argv);
533 return RUN_ALL_TESTS();
bool LineSegmentIntersection(const cv::Vec2d &p1, const cv::Vec2d &p2, const cv::Vec2d &p3, const cv::Vec2d &p4, cv::Vec2d &c)
TEST(IntersectionTests, Intersects)
int main(int argc, char **argv)
bool LineIntersection(const cv::Vec2d &p1, const cv::Vec2d &p2, const cv::Vec2d &p3, const cv::Vec2d &p4, cv::Vec2d &c)