|
|
@@ -242,3 +242,29 @@ TEST(CircleTest, NonIntersecting) {
|
|
|
square const sq{{{1.5, 0.5}}, 0.5};
|
|
|
EXPECT_FALSE(math::intersects(c1, sq));
|
|
|
}
|
|
|
+
|
|
|
+TEST(RotateTest, RotatingSquareAroundOrigin) {
|
|
|
+ math::degree degrees{90.0};
|
|
|
+ // A square with a side-length of 2 and a center at the origin
|
|
|
+ math::vec2 const origin = make_vector(0.f, 0.f);
|
|
|
+ quad const object = square{{{-1, -1}}, 2};
|
|
|
+ quad const rotated = math::rotate(origin, object, degrees);
|
|
|
+ EXPECT_THAT(rotated.ll, Eq(make_vector(1.f, -1.f)));
|
|
|
+ EXPECT_THAT(rotated.lr, Eq(make_vector(1.f, 1.f)));
|
|
|
+ EXPECT_THAT(rotated.ur, Eq(make_vector(-1.f, 1.f)));
|
|
|
+ EXPECT_THAT(rotated.ul, Eq(make_vector(-1.f, -1.f)));
|
|
|
+ EXPECT_THAT(math::rotate(origin, rotated, -degrees), Eq(object));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(RotateTest, RotatingSquareAroundOwnPoint) {
|
|
|
+ math::degree degrees{90.0};
|
|
|
+ // A square with a side-length of 2 and a center at the origin
|
|
|
+ math::vec2 const axis = make_vector(-1.f, -1.f);
|
|
|
+ quad const object = square{{{-1, -1}}, 2};
|
|
|
+ quad const rotated = math::rotate(axis, object, degrees);
|
|
|
+ EXPECT_THAT(rotated.ll, Eq(make_vector(-1.f, -1.f)));
|
|
|
+ EXPECT_THAT(rotated.lr, Eq(make_vector(-1.f, 1.f)));
|
|
|
+ EXPECT_THAT(rotated.ur, Eq(make_vector(-3.f, 1.f)));
|
|
|
+ EXPECT_THAT(rotated.ul, Eq(make_vector(-3.f, -1.f)));
|
|
|
+ EXPECT_THAT(math::rotate(axis, rotated, -degrees), Eq(object));
|
|
|
+}
|