1 #include <msp/geometry/rectangle.h>
2 #include <msp/geometry/transformedshape.h>
3 #include <msp/test/test.h>
7 class TransformedShapeTests: public Test::RegisteredTest<TransformedShapeTests>
10 TransformedShapeTests();
12 static const char *get_name() { return "TransformedShape"; }
15 void ray_intersection();
18 TransformedShapeTests::TransformedShapeTests()
20 add(&TransformedShapeTests::ray_intersection, "Ray intersection");
23 void TransformedShapeTests::ray_intersection()
25 Geometry::TransformedShape<double, 2> shape(Geometry::Rectangle<double>(2, 1), Geometry::AffineTransformation<double, 2>::rotation(Geometry::Angle<double>::from_degrees(45)));
26 Geometry::Ray<double, 2> ray(LinAl::Vector<double, 2>(3, 1.05), LinAl::Vector<double, 2>(-1, 0));
27 EXPECT(shape.check_intersection(ray));
28 ray = Geometry::Ray<double, 2>(LinAl::Vector<double, 2>(2.65, 3.35), LinAl::Vector<double, 2>(-1, -1));
29 EXPECT(shape.check_intersection(ray));
30 ray = Geometry::Ray<double, 2>(LinAl::Vector<double, 2>(2.6, 3.4), LinAl::Vector<double, 2>(-1, -1));
31 EXPECT(!shape.check_intersection(ray));