]> git.tdb.fi Git - libs/math.git/blob - tests/box.cpp
Redesign the Vector interface
[libs/math.git] / tests / box.cpp
1 #include <msp/geometry/box.h>
2 #include <msp/test/test.h>
3
4 using namespace Msp;
5
6 class HyperBoxTests: public Test::RegisteredTest<HyperBoxTests>
7 {
8 public:
9         HyperBoxTests();
10
11         static const char *get_name() { return "HyperBox"; }
12
13 private:
14         void ray_intersection();
15 };
16
17 HyperBoxTests::HyperBoxTests()
18 {
19         add(&HyperBoxTests::ray_intersection, "Ray intersection");
20 }
21
22 void HyperBoxTests::ray_intersection()
23 {
24         Geometry::Box<double> box(2, 4, 3);
25         Geometry::Ray<double, 3> ray(LinAl::Vector<double, 3>(10, 0, 0), LinAl::Vector<double, 3>(-1, 0, 0));
26         EXPECT(box.check_intersection(ray));
27         ray = Geometry::Ray<double, 3>(LinAl::Vector<double, 3>(10, 0, 0), LinAl::Vector<double, 3>(1, 0, 0));
28         EXPECT(!box.check_intersection(ray));
29         ray = Geometry::Ray<double, 3>(LinAl::Vector<double, 3>(9, 0, 11.45), LinAl::Vector<double, 3>(-1, 0, -1));
30         EXPECT(box.check_intersection(ray));
31         ray = Geometry::Ray<double, 3>(LinAl::Vector<double, 3>(9, 0, 11.55), LinAl::Vector<double, 3>(-1, 0, -1));
32         EXPECT(!box.check_intersection(ray));
33 }