1 #include <msp/geometry/box.h>
2 #include <msp/linal/vector3.h>
3 #include <msp/test/test.h>
7 class HyperBoxTests: public Test::RegisteredTest<HyperBoxTests>
12 static const char *get_name() { return "HyperBox"; }
15 void ray_intersection();
18 HyperBoxTests::HyperBoxTests()
20 add(&HyperBoxTests::ray_intersection, "Ray intersection");
23 void HyperBoxTests::ray_intersection()
25 Geometry::Box<double> box(2, 4, 3);
26 Geometry::Ray<double, 3> ray(LinAl::Vector3<double>(10, 0, 0), LinAl::Vector3<double>(-1, 0, 0));
27 EXPECT(box.check_intersection(ray));
28 ray = Geometry::Ray<double, 3>(LinAl::Vector3<double>(10, 0, 0), LinAl::Vector3<double>(1, 0, 0));
29 EXPECT(!box.check_intersection(ray));
30 ray = Geometry::Ray<double, 3>(LinAl::Vector3<double>(9, 0, 11.45), LinAl::Vector3<double>(-1, 0, -1));
31 EXPECT(box.check_intersection(ray));
32 ray = Geometry::Ray<double, 3>(LinAl::Vector3<double>(9, 0, 11.55), LinAl::Vector3<double>(-1, 0, -1));
33 EXPECT(!box.check_intersection(ray));