Skip to content
Snippets Groups Projects
Commit fb3993cf authored by Karsten Rink's avatar Karsten Rink
Browse files

adjusted indentation and comments for tests

parent f3aad421
No related branches found
No related tags found
1 merge request!447Minimal bounding spheres for points
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
TEST(GeoLib, TestBoundingSphere) TEST(GeoLib, TestBoundingSphere)
{ {
GeoLib::Point a(0, 0 ,0); GeoLib::Point a(0, 0 ,0);
GeoLib::Point b(2, 0 ,0); GeoLib::Point b(2, 0 ,0);
GeoLib::Point c(1, 0.1 ,0); GeoLib::Point c(1, 0.1 ,0);
GeoLib::Point d(1, -0.1 ,0); GeoLib::Point d(1, -0.1 ,0);
std::vector<GeoLib::Point*> pnts; std::vector<GeoLib::Point*> pnts;
pnts.push_back(new GeoLib::Point(0, 0 , 0)); pnts.push_back(new GeoLib::Point(0, 0 , 0));
pnts.push_back(new GeoLib::Point(2, 0 , 0)); pnts.push_back(new GeoLib::Point(2, 0 , 0));
...@@ -30,8 +30,18 @@ TEST(GeoLib, TestBoundingSphere) ...@@ -30,8 +30,18 @@ TEST(GeoLib, TestBoundingSphere)
pnts.push_back(new GeoLib::Point(1, -0.1 , 0)); pnts.push_back(new GeoLib::Point(1, -0.1 , 0));
{ {
/**
* Four points located like this:
*
* *
* * *
* *
*
* Tests if a smaller number of points than available is used if the resulting sphere is smaller.
* Expected result is C=(1,0,0), r=1
*/
GeoLib::BoundingSphere s(pnts); GeoLib::BoundingSphere s(pnts);
GeoLib::Point center = s.getCenter(); GeoLib::Point center = s.getCenter();
ASSERT_NEAR(1.0, center[0], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(1.0, center[0], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(0.0, center[1], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.0, center[1], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(0.0, center[2], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.0, center[2], std::numeric_limits<double>::epsilon());
...@@ -39,9 +49,21 @@ TEST(GeoLib, TestBoundingSphere) ...@@ -39,9 +49,21 @@ TEST(GeoLib, TestBoundingSphere)
} }
{ {
/**
* Four points located like this:
*
* *
* * *
*
*
* *
*
* The smallest sphere has a diameter that is larger than the distance between any two points.
* Expected result is C=(1,0.0246,-0.3446), r=1.058
*/
(*pnts[2])[2] -= 1.4; (*pnts[2])[2] -= 1.4;
GeoLib::BoundingSphere s(pnts); GeoLib::BoundingSphere s(pnts);
GeoLib::Point center = s.getCenter(); GeoLib::Point center = s.getCenter();
ASSERT_NEAR(1.0, center[0], 0.0001); ASSERT_NEAR(1.0, center[0], 0.0001);
ASSERT_NEAR(0.0246, center[1], 0.0001); ASSERT_NEAR(0.0246, center[1], 0.0001);
ASSERT_NEAR(-0.3446, center[2], 0.0001); ASSERT_NEAR(-0.3446, center[2], 0.0001);
...@@ -58,8 +80,12 @@ TEST(GeoLib, TestBoundingSphere) ...@@ -58,8 +80,12 @@ TEST(GeoLib, TestBoundingSphere)
pnts.push_back(new GeoLib::Point(0, 1, 0.9)); pnts.push_back(new GeoLib::Point(0, 1, 0.9));
{ {
/**
* A "cube" where one node is pushed slightly towards the centre (and should be ignored).
* Expected result is C=(0.5,0.5,0.5), r=0.866
*/
GeoLib::BoundingSphere s(pnts); GeoLib::BoundingSphere s(pnts);
GeoLib::Point center = s.getCenter(); GeoLib::Point center = s.getCenter();
ASSERT_NEAR(0.5, center[0], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.5, center[0], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(0.5, center[1], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.5, center[1], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(0.5, center[2], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.5, center[2], std::numeric_limits<double>::epsilon());
...@@ -67,9 +93,13 @@ TEST(GeoLib, TestBoundingSphere) ...@@ -67,9 +93,13 @@ TEST(GeoLib, TestBoundingSphere)
} }
{ {
/**
* A "cube" where one node is pulled away from the centre (making the resulting sphere larger).
* Expected result is C=(0.5,0.5,0.6), r=0.9273
*/
(*pnts[7])[2] += 0.3; (*pnts[7])[2] += 0.3;
GeoLib::BoundingSphere s(pnts); GeoLib::BoundingSphere s(pnts);
GeoLib::Point center = s.getCenter(); GeoLib::Point center = s.getCenter();
ASSERT_NEAR(0.5, center[0], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.5, center[0], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(0.5, center[1], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.5, center[1], std::numeric_limits<double>::epsilon());
ASSERT_NEAR(0.6, center[2], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.6, center[2], std::numeric_limits<double>::epsilon());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment