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