X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=tests%2Fbox.cpp;fp=tests%2Fbox.cpp;h=860bb4e511a059ab3fd5c3340c8fc1785dd4d109;hb=eb02e224876676a2d78f7305456a7d6f67d3dee2;hp=0000000000000000000000000000000000000000;hpb=6ff13022b53830d35283905d562c2ef3af198cc1;p=libs%2Fmath.git diff --git a/tests/box.cpp b/tests/box.cpp new file mode 100644 index 0000000..860bb4e --- /dev/null +++ b/tests/box.cpp @@ -0,0 +1,34 @@ +#include +#include +#include + +using namespace Msp; + +class HyperBoxTests: public Test::RegisteredTest +{ +public: + HyperBoxTests(); + + static const char *get_name() { return "HyperBox"; } + +private: + void ray_intersection(); +}; + +HyperBoxTests::HyperBoxTests() +{ + add(&HyperBoxTests::ray_intersection, "Ray intersection"); +} + +void HyperBoxTests::ray_intersection() +{ + Geometry::Box box(2, 4, 3); + Geometry::Ray ray(LinAl::Vector3(10, 0, 0), LinAl::Vector3(-1, 0, 0)); + EXPECT(box.check_intersection(ray)); + ray = Geometry::Ray(LinAl::Vector3(10, 0, 0), LinAl::Vector3(1, 0, 0)); + EXPECT(!box.check_intersection(ray)); + ray = Geometry::Ray(LinAl::Vector3(9, 0, 11.45), LinAl::Vector3(-1, 0, -1)); + EXPECT(box.check_intersection(ray)); + ray = Geometry::Ray(LinAl::Vector3(9, 0, 11.55), LinAl::Vector3(-1, 0, -1)); + EXPECT(!box.check_intersection(ray)); +}