]> git.tdb.fi Git - libs/math.git/blob - tests/transformedshape.cpp
Some basic test cases
[libs/math.git] / tests / transformedshape.cpp
1 #include <msp/geometry/rectangle.h>
2 #include <msp/geometry/transformedshape.h>
3 #include <msp/test/test.h>
4
5 using namespace Msp;
6
7 class TransformedShapeTests: public Test::RegisteredTest<TransformedShapeTests>
8 {
9 public:
10         TransformedShapeTests();
11
12         static const char *get_name() { return "TransformedShape"; }
13
14 private:
15         void ray_intersection();
16 };
17
18 TransformedShapeTests::TransformedShapeTests()
19 {
20         add(&TransformedShapeTests::ray_intersection, "Ray intersection");
21 }
22
23 void TransformedShapeTests::ray_intersection()
24 {
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::Vector2<double>(3, 1.05), LinAl::Vector2<double>(-1, 0));
27         EXPECT(shape.check_intersection(ray));
28         ray = Geometry::Ray<double, 2>(LinAl::Vector2<double>(2.65, 3.35), LinAl::Vector2<double>(-1, -1));
29         EXPECT(shape.check_intersection(ray));
30         ray = Geometry::Ray<double, 2>(LinAl::Vector2<double>(2.6, 3.4), LinAl::Vector2<double>(-1, -1));
31         EXPECT(!shape.check_intersection(ray));
32 }