| 12 | { |
| 13 | |
| 14 | TEST(ObbTest, obb) |
| 15 | { |
| 16 | auto doesIntersect = [](Obb c) |
| 17 | { |
| 18 | NL::json base = R"( |
| 19 | { |
| 20 | "center" : [ 0, 0, 0 ], |
| 21 | "halfSize" : [ 2, 1, 1.5 ], |
| 22 | "quaternion" : [ 0, 0, 0, 1 ] |
| 23 | } |
| 24 | )"_json; |
| 25 | Obb b(base); |
| 26 | EXPECT_EQ(b.intersect(c), c.intersect(b)); |
| 27 | return b.intersect(c); |
| 28 | }; |
| 29 | |
| 30 | NL::json clip = R"( |
| 31 | { |
| 32 | "center" : [ 2, 1, 0 ], |
| 33 | "halfSize" : [ |
| 34 | 2.12132034355, |
| 35 | 0.707106781186, |
| 36 | 1 |
| 37 | ], |
| 38 | "quaternion" : [ |
| 39 | 0, |
| 40 | 0, |
| 41 | -0.3826834324, |
| 42 | 0.9238795325 |
| 43 | ] |
| 44 | } |
| 45 | )"_json; |
| 46 | |
| 47 | Obb c(clip); |
| 48 | EXPECT_TRUE(doesIntersect(c)); |
| 49 | c.setCenter({2, 1, -1}); |
| 50 | EXPECT_TRUE(doesIntersect(c)); |
| 51 | c.setCenter({2, 1, -2.5}); |
| 52 | EXPECT_TRUE(doesIntersect(c)); |
| 53 | c.setCenter({2, 1, -2.51}); |
| 54 | EXPECT_FALSE(doesIntersect(c)); |
| 55 | c.setCenter({2, 3, 0}); |
| 56 | EXPECT_FALSE(doesIntersect(c)); |
| 57 | c.setCenter({2, 2, 0}); |
| 58 | EXPECT_TRUE(doesIntersect(c)); |
| 59 | } |
| 60 | |
| 61 | } // namespace i3s |
| 62 | } // namespace pdal |