|
|
@@ -261,14 +261,46 @@ TEST(TriangleTest, DoesNotIntersectOffset) {
|
|
|
math::dim2::point const clock_bc{{-1, -1}};
|
|
|
math::dim2::point const clock_ca{{-1, 2}};
|
|
|
|
|
|
+ // Each of these expectations fails one of the check-edges calls
|
|
|
+ // in the intersection algorithm, which proves that each point of
|
|
|
+ // the triangle is not within (or on) the bounds of the other triangle
|
|
|
+ // Each of these tests indicates one edge of the triangle 'lhs', and
|
|
|
+ // tests for whether it orients around any of the points of the other
|
|
|
+ // 'triangle'.
|
|
|
+ // Tests are done for each edge vs. the the opposite triangle,
|
|
|
+ // starting with edges for the lhs, and then the edges on the rhs.
|
|
|
EXPECT_FALSE(math::intersects(lhs, tri(clock_ab)));
|
|
|
- EXPECT_FALSE(math::intersects(tri(clock_ab), lhs));
|
|
|
EXPECT_FALSE(math::intersects(lhs, tri(clock_bc)));
|
|
|
- EXPECT_FALSE(math::intersects(tri(clock_bc), lhs));
|
|
|
EXPECT_FALSE(math::intersects(lhs, tri(clock_ca)));
|
|
|
+ EXPECT_FALSE(math::intersects(tri(clock_ab), lhs));
|
|
|
+ EXPECT_FALSE(math::intersects(tri(clock_bc), lhs));
|
|
|
EXPECT_FALSE(math::intersects(tri(clock_ca), lhs));
|
|
|
}
|
|
|
|
|
|
+TEST(QuadTest, IntersectsContain) {
|
|
|
+ quad const lhs = square{{{-0.5f, -0.5f}}, 1};
|
|
|
+ quad const rhs = square{{{-.25f, -.25f}}, 0.5};
|
|
|
+ EXPECT_TRUE(math::intersects(lhs, rhs));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(QuadTest, NoIntersectionAtEdge) {
|
|
|
+ quad const lhs = square{{{-0.5f, -0.5f}}, 1};
|
|
|
+ quad const rhs = square{{{ 0.0f, 0.5f}}, 1};
|
|
|
+ EXPECT_FALSE(math::intersects(lhs, rhs));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(QuadTest, NoIntersectionAtCorner) {
|
|
|
+ quad const lhs = square{{{-0.5f, -0.5f}}, 1};
|
|
|
+ quad const rhs = square{{{ 0.5f, 0.5f}}, 1};
|
|
|
+ EXPECT_FALSE(math::intersects(lhs, rhs));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(QuadTest, NoIntersection) {
|
|
|
+ quad const lhs = square{{{-1.0f, -0.5f}}, 1};
|
|
|
+ quad const rhs = square{{{ 0.5f, 0.5f}}, 1};
|
|
|
+ EXPECT_FALSE(math::intersects(lhs, rhs));
|
|
|
+}
|
|
|
+
|
|
|
TEST(RotateTest, RotatingSquareAroundOrigin) {
|
|
|
math::degree degrees{90.0};
|
|
|
// A square with a side-length of 2 and a center at the origin
|