| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2014 Frederik Heber. All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | *
|
|---|
| 7 | * This file is part of MoleCuilder.
|
|---|
| 8 | *
|
|---|
| 9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
|---|
| 10 | * it under the terms of the GNU General Public License as published by
|
|---|
| 11 | * the Free Software Foundation, either version 2 of the License, or
|
|---|
| 12 | * (at your option) any later version.
|
|---|
| 13 | *
|
|---|
| 14 | * MoleCuilder is distributed in the hope that it will be useful,
|
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | * GNU General Public License for more details.
|
|---|
| 18 | *
|
|---|
| 19 | * You should have received a copy of the GNU General Public License
|
|---|
| 20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 21 | */
|
|---|
| 22 |
|
|---|
| 23 | /*
|
|---|
| 24 | * SphericalPointDistributionUnitTest.cpp
|
|---|
| 25 | *
|
|---|
| 26 | * Created on: May 29, 2014
|
|---|
| 27 | * Author: heber
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | // include config.h
|
|---|
| 31 | #ifdef HAVE_CONFIG_H
|
|---|
| 32 | #include <config.h>
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 | using namespace std;
|
|---|
| 36 |
|
|---|
| 37 | #include <cppunit/CompilerOutputter.h>
|
|---|
| 38 | #include <cppunit/extensions/TestFactoryRegistry.h>
|
|---|
| 39 | #include <cppunit/ui/text/TestRunner.h>
|
|---|
| 40 |
|
|---|
| 41 | // include headers that implement a archive in simple text format
|
|---|
| 42 | #include <boost/archive/text_oarchive.hpp>
|
|---|
| 43 | #include <boost/archive/text_iarchive.hpp>
|
|---|
| 44 |
|
|---|
| 45 | #include "SphericalPointDistributionUnitTest.hpp"
|
|---|
| 46 |
|
|---|
| 47 | #include <algorithm>
|
|---|
| 48 | #include <boost/assign.hpp>
|
|---|
| 49 | #include <boost/math/quaternion.hpp>
|
|---|
| 50 |
|
|---|
| 51 | #include "CodePatterns/Assert.hpp"
|
|---|
| 52 | #include "CodePatterns/Log.hpp"
|
|---|
| 53 |
|
|---|
| 54 | #include "LinearAlgebra/Line.hpp"
|
|---|
| 55 |
|
|---|
| 56 | #include "Atom/TesselPoint.hpp"
|
|---|
| 57 | #include "Fragmentation/Exporters/SphericalPointDistribution.hpp"
|
|---|
| 58 | #include "LinkedCell/linkedcell.hpp"
|
|---|
| 59 | #include "LinkedCell/PointCloudAdaptor.hpp"
|
|---|
| 60 | #include "Tesselation/BoundaryLineSet.hpp"
|
|---|
| 61 | #include "Tesselation/tesselation.hpp"
|
|---|
| 62 |
|
|---|
| 63 | #ifdef HAVE_TESTRUNNER
|
|---|
| 64 | #include "UnitTestMain.hpp"
|
|---|
| 65 | #endif /*HAVE_TESTRUNNER*/
|
|---|
| 66 |
|
|---|
| 67 | using namespace boost::assign;
|
|---|
| 68 |
|
|---|
| 69 | /********************************************** Test classes **************************************/
|
|---|
| 70 |
|
|---|
| 71 | // Registers the fixture into the 'registry'
|
|---|
| 72 | CPPUNIT_TEST_SUITE_REGISTRATION( SphericalPointDistributionTest );
|
|---|
| 73 |
|
|---|
| 74 | /** due to root-taking in function we only have limited numerical precision,
|
|---|
| 75 | * basically half of the double range.
|
|---|
| 76 | */
|
|---|
| 77 | const double CenterAccuracy = sqrt(std::numeric_limits<double>::epsilon()*1e2);
|
|---|
| 78 |
|
|---|
| 79 | void SphericalPointDistributionTest::setUp()
|
|---|
| 80 | {
|
|---|
| 81 | // failing asserts should be thrown
|
|---|
| 82 | ASSERT_DO(Assert::Throw);
|
|---|
| 83 |
|
|---|
| 84 | setVerbosity(2);
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | void SphericalPointDistributionTest::tearDown()
|
|---|
| 89 | {
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | /** UnitTest for calculateCenterOfMinimumDistance()
|
|---|
| 93 | */
|
|---|
| 94 | void SphericalPointDistributionTest::calculateCenterOfMinimumDistanceTest()
|
|---|
| 95 | {
|
|---|
| 96 | // single point
|
|---|
| 97 | {
|
|---|
| 98 | SphericalPointDistribution::VectorArray_t points;
|
|---|
| 99 | points +=
|
|---|
| 100 | Vector(1.,0.,0.);
|
|---|
| 101 | SphericalPointDistribution::IndexList_t indices;
|
|---|
| 102 | indices += 0;
|
|---|
| 103 | const Vector expected = points[0];
|
|---|
| 104 | const Vector center =
|
|---|
| 105 | SphericalPointDistribution::calculateCenterOfMinimumDistance(points, indices);
|
|---|
| 106 | // std::cout << " Difference is " << (expected - center).Norm() << std::endl;
|
|---|
| 107 | // CPPUNIT_ASSERT_EQUAL ( expected, center );
|
|---|
| 108 | CPPUNIT_ASSERT( expected.IsEqualTo(center, CenterAccuracy));
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | // single point, rotated
|
|---|
| 112 | {
|
|---|
| 113 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 114 | SphericalPointDistribution::VectorArray_t points;
|
|---|
| 115 | points +=
|
|---|
| 116 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI);
|
|---|
| 117 | SphericalPointDistribution::IndexList_t indices;
|
|---|
| 118 | indices += 0;
|
|---|
| 119 | const Vector expected = points[0];
|
|---|
| 120 | const Vector center =
|
|---|
| 121 | SphericalPointDistribution::calculateCenterOfMinimumDistance(points, indices);
|
|---|
| 122 | // std::cout << " Difference is " << (expected - center).Norm() << std::endl;
|
|---|
| 123 | // CPPUNIT_ASSERT_EQUAL ( expected, center );
|
|---|
| 124 | CPPUNIT_ASSERT( expected.IsEqualTo(center, CenterAccuracy));
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | // two points
|
|---|
| 128 | {
|
|---|
| 129 | SphericalPointDistribution::VectorArray_t points;
|
|---|
| 130 | points +=
|
|---|
| 131 | Vector(1.,0.,0.),
|
|---|
| 132 | Vector(0.,1.,0.);
|
|---|
| 133 | SphericalPointDistribution::IndexList_t indices;
|
|---|
| 134 | indices += 0,1;
|
|---|
| 135 | const Vector expected = Vector(M_SQRT1_2,M_SQRT1_2,0.);
|
|---|
| 136 | const Vector center =
|
|---|
| 137 | SphericalPointDistribution::calculateCenterOfMinimumDistance(points, indices);
|
|---|
| 138 | // std::cout << " Difference is " << (expected - center).Norm() << std::endl;
|
|---|
| 139 | // CPPUNIT_ASSERT_EQUAL ( expected, center );
|
|---|
| 140 | CPPUNIT_ASSERT( expected.IsEqualTo(center, CenterAccuracy));
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | // two points, rotated
|
|---|
| 144 | {
|
|---|
| 145 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 146 | SphericalPointDistribution::VectorArray_t points;
|
|---|
| 147 | points +=
|
|---|
| 148 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 149 | RotationAxis.rotateVector(Vector(0.,1.,0.), 47.6/180*M_PI);
|
|---|
| 150 | SphericalPointDistribution::IndexList_t indices;
|
|---|
| 151 | indices += 0,1;
|
|---|
| 152 | const Vector expected = RotationAxis.rotateVector(Vector(M_SQRT1_2,M_SQRT1_2,0.), 47.6/180*M_PI);
|
|---|
| 153 | const Vector center =
|
|---|
| 154 | SphericalPointDistribution::calculateCenterOfMinimumDistance(points, indices);
|
|---|
| 155 | // std::cout << " Difference is " << (expected - center).Norm() << std::endl;
|
|---|
| 156 | // CPPUNIT_ASSERT_EQUAL ( expected, center );
|
|---|
| 157 | CPPUNIT_ASSERT( expected.IsEqualTo(center, CenterAccuracy));
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | // three points in line
|
|---|
| 161 | {
|
|---|
| 162 | SphericalPointDistribution::VectorArray_t points;
|
|---|
| 163 | points +=
|
|---|
| 164 | Vector(1.,0.,0.),
|
|---|
| 165 | Vector(0.,1.,0.),
|
|---|
| 166 | Vector(-1.,0.,0.);
|
|---|
| 167 | SphericalPointDistribution::IndexList_t indices;
|
|---|
| 168 | indices += 0,1,2;
|
|---|
| 169 | const Vector expected = points[1];
|
|---|
| 170 | const Vector center =
|
|---|
| 171 | SphericalPointDistribution::calculateCenterOfMinimumDistance(points, indices);
|
|---|
| 172 | // std::cout << " Difference is " << (expected - center).Norm() << std::endl;
|
|---|
| 173 | // CPPUNIT_ASSERT_EQUAL ( expected, center );
|
|---|
| 174 | CPPUNIT_ASSERT( expected.IsEqualTo(center, CenterAccuracy));
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | // three points in line, rotated
|
|---|
| 178 | {
|
|---|
| 179 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 180 | SphericalPointDistribution::VectorArray_t points;
|
|---|
| 181 | points +=
|
|---|
| 182 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 183 | RotationAxis.rotateVector(Vector(0.,1.,0.), 47.6/180*M_PI),
|
|---|
| 184 | RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
|
|---|
| 185 | SphericalPointDistribution::IndexList_t indices;
|
|---|
| 186 | indices += 0,1,2;
|
|---|
| 187 | const Vector expected = points[1];
|
|---|
| 188 | const Vector center =
|
|---|
| 189 | SphericalPointDistribution::calculateCenterOfMinimumDistance(points, indices);
|
|---|
| 190 | // std::cout << " Difference is " << (expected - center).Norm() << std::endl;
|
|---|
| 191 | // CPPUNIT_ASSERT_EQUAL ( expected, center );
|
|---|
| 192 | CPPUNIT_ASSERT( expected.IsEqualTo(center, CenterAccuracy));
|
|---|
| 193 | }
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | static
|
|---|
| 197 | bool areEqualToWithinBounds(
|
|---|
| 198 | const SphericalPointDistribution::Polygon_t &_polygon,
|
|---|
| 199 | const SphericalPointDistribution::Polygon_t &_otherpolygon,
|
|---|
| 200 | double _amplitude
|
|---|
| 201 | )
|
|---|
| 202 | {
|
|---|
| 203 | // same size?
|
|---|
| 204 | if (_polygon.size() != _otherpolygon.size())
|
|---|
| 205 | return false;
|
|---|
| 206 | // same points ? We just check witrh trivial mapping, nothing fancy ...
|
|---|
| 207 | bool status = true;
|
|---|
| 208 | SphericalPointDistribution::Polygon_t::const_iterator iter = _polygon.begin();
|
|---|
| 209 | SphericalPointDistribution::Polygon_t::const_iterator otheriter = _otherpolygon.begin();
|
|---|
| 210 | for (; iter != _polygon.end(); ++iter, ++otheriter) {
|
|---|
| 211 | status &= (*iter).IsEqualTo(*otheriter, _amplitude);
|
|---|
| 212 | }
|
|---|
| 213 | return status;
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | /** UnitTest for areEqualToWithinBounds()
|
|---|
| 217 | */
|
|---|
| 218 | void SphericalPointDistributionTest::areEqualToWithinBoundsTest()
|
|---|
| 219 | {
|
|---|
| 220 | // test with no points
|
|---|
| 221 | {
|
|---|
| 222 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 223 | SphericalPointDistribution::Polygon_t expected = polygon;
|
|---|
| 224 | CPPUNIT_ASSERT( areEqualToWithinBounds(polygon, expected, std::numeric_limits<double>::epsilon()*1e2) );
|
|---|
| 225 | }
|
|---|
| 226 | // test with one point
|
|---|
| 227 | {
|
|---|
| 228 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 229 | polygon += Vector(1.,0.,0.);
|
|---|
| 230 | SphericalPointDistribution::Polygon_t expected = polygon;
|
|---|
| 231 | CPPUNIT_ASSERT( areEqualToWithinBounds(polygon, expected, std::numeric_limits<double>::epsilon()*1e2) );
|
|---|
| 232 | }
|
|---|
| 233 | // test with two points
|
|---|
| 234 | {
|
|---|
| 235 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 236 | polygon += Vector(1.,0.,0.);
|
|---|
| 237 | polygon += Vector(0.,1.,0.);
|
|---|
| 238 | SphericalPointDistribution::Polygon_t expected = polygon;
|
|---|
| 239 | CPPUNIT_ASSERT( areEqualToWithinBounds(polygon, expected, std::numeric_limits<double>::epsilon()*1e2) );
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | // test with two points in different order: THIS GOES WRONG: We only check trivially
|
|---|
| 243 | {
|
|---|
| 244 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 245 | polygon += Vector(1.,0.,0.);
|
|---|
| 246 | polygon += Vector(0.,1.,0.);
|
|---|
| 247 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 248 | expected += Vector(0.,1.,0.);
|
|---|
| 249 | expected += Vector(1.,0.,0.);
|
|---|
| 250 | CPPUNIT_ASSERT( !areEqualToWithinBounds(polygon, expected, std::numeric_limits<double>::epsilon()*1e2) );
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | // test with two different points
|
|---|
| 254 | {
|
|---|
| 255 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 256 | polygon += Vector(1.,0.,0.);
|
|---|
| 257 | polygon += Vector(0.,1.,0.);
|
|---|
| 258 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 259 | expected += Vector(1.01,0.,0.);
|
|---|
| 260 | expected += Vector(0.,1.,0.);
|
|---|
| 261 | CPPUNIT_ASSERT( areEqualToWithinBounds(polygon, expected, 0.05) );
|
|---|
| 262 | CPPUNIT_ASSERT( !areEqualToWithinBounds(polygon, expected, 0.005) );
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | // test with different number of points
|
|---|
| 266 | {
|
|---|
| 267 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 268 | polygon += Vector(1.,0.,0.);
|
|---|
| 269 | polygon += Vector(0.,1.,0.);
|
|---|
| 270 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 271 | expected += Vector(0.,1.,0.);
|
|---|
| 272 | CPPUNIT_ASSERT( !areEqualToWithinBounds(polygon, expected, 0.05) );
|
|---|
| 273 | }
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 | /** UnitTest for getConnections()
|
|---|
| 277 | */
|
|---|
| 278 | template <>
|
|---|
| 279 | void SphericalPointDistributionTest_assistant::getConnectionTest<0>()
|
|---|
| 280 | {
|
|---|
| 281 | const int N=0;
|
|---|
| 282 | SphericalPointDistribution SPD(1.);
|
|---|
| 283 |
|
|---|
| 284 | // create empty adjacency
|
|---|
| 285 | SphericalPointDistribution::adjacency_t adjacency;
|
|---|
| 286 |
|
|---|
| 287 | // get the implemented connections
|
|---|
| 288 | SphericalPointDistribution::adjacency_t expected =
|
|---|
| 289 | SPD.getConnections<N>();
|
|---|
| 290 |
|
|---|
| 291 | // and compare the two
|
|---|
| 292 | CPPUNIT_ASSERT_EQUAL( expected, adjacency );
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | /** UnitTest for getConnections()
|
|---|
| 296 | */
|
|---|
| 297 | template <>
|
|---|
| 298 | void SphericalPointDistributionTest_assistant::getConnectionTest<1>()
|
|---|
| 299 | {
|
|---|
| 300 | const int N=1;
|
|---|
| 301 | SphericalPointDistribution SPD(1.);
|
|---|
| 302 |
|
|---|
| 303 | // create empty adjacency
|
|---|
| 304 | SphericalPointDistribution::adjacency_t adjacency;
|
|---|
| 305 |
|
|---|
| 306 | // get the implemented connections
|
|---|
| 307 | SphericalPointDistribution::adjacency_t expected =
|
|---|
| 308 | SPD.getConnections<N>();
|
|---|
| 309 |
|
|---|
| 310 | // and compare the two
|
|---|
| 311 | CPPUNIT_ASSERT_EQUAL( expected, adjacency );
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | /** UnitTest for getConnections()
|
|---|
| 315 | */
|
|---|
| 316 | template <>
|
|---|
| 317 | void SphericalPointDistributionTest_assistant::getConnectionTest<2>()
|
|---|
| 318 | {
|
|---|
| 319 | const int N=2;
|
|---|
| 320 | SphericalPointDistribution SPD(1.);
|
|---|
| 321 |
|
|---|
| 322 | // create empty adjacency
|
|---|
| 323 | SphericalPointDistribution::adjacency_t adjacency;
|
|---|
| 324 | adjacency +=
|
|---|
| 325 | make_pair<
|
|---|
| 326 | unsigned int,
|
|---|
| 327 | SphericalPointDistribution::IndexSet_t >
|
|---|
| 328 | (0, list_of<unsigned int>(1));
|
|---|
| 329 | adjacency +=
|
|---|
| 330 | make_pair<
|
|---|
| 331 | unsigned int,
|
|---|
| 332 | SphericalPointDistribution::IndexSet_t >
|
|---|
| 333 | (1, list_of<unsigned int>(0));
|
|---|
| 334 |
|
|---|
| 335 | // get the implemented connections
|
|---|
| 336 | SphericalPointDistribution::adjacency_t expected =
|
|---|
| 337 | SPD.getConnections<N>();
|
|---|
| 338 |
|
|---|
| 339 | // and compare the two
|
|---|
| 340 | CPPUNIT_ASSERT_EQUAL( expected, adjacency );
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | void perturbPolygon(
|
|---|
| 344 | SphericalPointDistribution::WeightedPolygon_t &_polygon,
|
|---|
| 345 | double _amplitude
|
|---|
| 346 | )
|
|---|
| 347 | {
|
|---|
| 348 | for (SphericalPointDistribution::WeightedPolygon_t::iterator iter = _polygon.begin();
|
|---|
| 349 | iter != _polygon.end(); ++iter) {
|
|---|
| 350 | Vector perturber;
|
|---|
| 351 | perturber.GetOneNormalVector(iter->first);
|
|---|
| 352 | perturber.Scale(_amplitude);
|
|---|
| 353 | iter->first = iter->first + perturber;
|
|---|
| 354 | (iter->first).Normalize();
|
|---|
| 355 | }
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 | /** UnitTest for joinPoints()
|
|---|
| 359 | */
|
|---|
| 360 | void SphericalPointDistributionTest::joinPointsTest()
|
|---|
| 361 | {
|
|---|
| 362 | // test with simple configuration of three points
|
|---|
| 363 | {
|
|---|
| 364 | SphericalPointDistribution::Polygon_t newpolygon;
|
|---|
| 365 | newpolygon += Vector(1.,0.,0.);
|
|---|
| 366 | newpolygon += Vector(0.,1.,0.);
|
|---|
| 367 | newpolygon += Vector(0.,0.,1.);
|
|---|
| 368 | SphericalPointDistribution::Polygon_t expectedpolygon = newpolygon;
|
|---|
| 369 | SphericalPointDistribution::IndexTupleList_t matching;
|
|---|
| 370 | matching += SphericalPointDistribution::IndexList_t(1,0);
|
|---|
| 371 | matching += SphericalPointDistribution::IndexList_t(1,1);
|
|---|
| 372 | matching += SphericalPointDistribution::IndexList_t(1,2);
|
|---|
| 373 | SphericalPointDistribution::IndexList_t IndexList =
|
|---|
| 374 | SphericalPointDistribution::joinPoints(
|
|---|
| 375 | newpolygon,
|
|---|
| 376 | SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
|
|---|
| 377 | matching);
|
|---|
| 378 | SphericalPointDistribution::IndexList_t expected;
|
|---|
| 379 | expected += 0,1,2;
|
|---|
| 380 | CPPUNIT_ASSERT_EQUAL( expected, IndexList );
|
|---|
| 381 | CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
|
|---|
| 382 | }
|
|---|
| 383 |
|
|---|
| 384 | // test with simple configuration of three points, only two are picked
|
|---|
| 385 | {
|
|---|
| 386 | SphericalPointDistribution::Polygon_t newpolygon;
|
|---|
| 387 | newpolygon += Vector(1.,0.,0.);
|
|---|
| 388 | newpolygon += Vector(0.,1.,0.);
|
|---|
| 389 | newpolygon += Vector(0.,0.,1.);
|
|---|
| 390 | SphericalPointDistribution::Polygon_t expectedpolygon = newpolygon;
|
|---|
| 391 | SphericalPointDistribution::IndexTupleList_t matching;
|
|---|
| 392 | matching += SphericalPointDistribution::IndexList_t(1,1);
|
|---|
| 393 | matching += SphericalPointDistribution::IndexList_t(1,2);
|
|---|
| 394 | SphericalPointDistribution::IndexList_t IndexList =
|
|---|
| 395 | SphericalPointDistribution::joinPoints(
|
|---|
| 396 | newpolygon,
|
|---|
| 397 | SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
|
|---|
| 398 | matching);
|
|---|
| 399 | SphericalPointDistribution::IndexList_t expected;
|
|---|
| 400 | expected += 1,2;
|
|---|
| 401 | CPPUNIT_ASSERT_EQUAL( expected, IndexList );
|
|---|
| 402 | CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | // test with simple configuration of three points, two are joined
|
|---|
| 406 | {
|
|---|
| 407 | SphericalPointDistribution::Polygon_t newpolygon;
|
|---|
| 408 | newpolygon += Vector(1.,0.,0.);
|
|---|
| 409 | newpolygon += Vector(0.,1.,0.);
|
|---|
| 410 | newpolygon += Vector(0.,0.,1.);
|
|---|
| 411 | SphericalPointDistribution::Polygon_t expectedpolygon;
|
|---|
| 412 | expectedpolygon += Vector(1.,0.,0.);
|
|---|
| 413 | expectedpolygon += Vector(0.,M_SQRT1_2,M_SQRT1_2);
|
|---|
| 414 | SphericalPointDistribution::IndexTupleList_t matching;
|
|---|
| 415 | SphericalPointDistribution::IndexList_t joined;
|
|---|
| 416 | joined += 1,2;
|
|---|
| 417 | matching += SphericalPointDistribution::IndexList_t(1,0);
|
|---|
| 418 | matching += joined;
|
|---|
| 419 | SphericalPointDistribution::IndexList_t IndexList =
|
|---|
| 420 | SphericalPointDistribution::joinPoints(
|
|---|
| 421 | newpolygon,
|
|---|
| 422 | SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
|
|---|
| 423 | matching);
|
|---|
| 424 | SphericalPointDistribution::IndexList_t expected;
|
|---|
| 425 | expected += 0,1;
|
|---|
| 426 | CPPUNIT_ASSERT_EQUAL( expected, IndexList );
|
|---|
| 427 | CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 | // test with simple configuration of six points, two are joined, jumbled indices
|
|---|
| 431 | {
|
|---|
| 432 | SphericalPointDistribution::Polygon_t newpolygon;
|
|---|
| 433 | newpolygon += Vector(1.,0.,1.);
|
|---|
| 434 | newpolygon += Vector(1.,0.,0.);
|
|---|
| 435 | newpolygon += Vector(1.,1.,0.);
|
|---|
| 436 | newpolygon += Vector(0.,1.,0.);
|
|---|
| 437 | newpolygon += Vector(0.,0.,1.);
|
|---|
| 438 | newpolygon += Vector(1.,0.,1.);
|
|---|
| 439 | SphericalPointDistribution::Polygon_t expectedpolygon;
|
|---|
| 440 | expectedpolygon += Vector(1.,0.,1.);
|
|---|
| 441 | expectedpolygon += Vector(1.,0.,0.);
|
|---|
| 442 | expectedpolygon += Vector(1.,1.,0.);
|
|---|
| 443 | expectedpolygon += Vector(1.,0.,1.);
|
|---|
| 444 | expectedpolygon += Vector(0.,M_SQRT1_2,M_SQRT1_2); // new centers go last
|
|---|
| 445 | SphericalPointDistribution::IndexTupleList_t matching;
|
|---|
| 446 | SphericalPointDistribution::IndexList_t joined;
|
|---|
| 447 | joined += 3,4;
|
|---|
| 448 | matching += SphericalPointDistribution::IndexList_t(1,1);
|
|---|
| 449 | matching += joined;
|
|---|
| 450 | SphericalPointDistribution::IndexList_t IndexList =
|
|---|
| 451 | SphericalPointDistribution::joinPoints(
|
|---|
| 452 | newpolygon,
|
|---|
| 453 | SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
|
|---|
| 454 | matching);
|
|---|
| 455 | SphericalPointDistribution::IndexList_t expected;
|
|---|
| 456 | expected += 1,4;
|
|---|
| 457 | CPPUNIT_ASSERT_EQUAL( expected, IndexList );
|
|---|
| 458 | CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
|
|---|
| 459 | }
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | /** UnitTest for getRemainingPoints() with two points
|
|---|
| 463 | */
|
|---|
| 464 | void SphericalPointDistributionTest::getRemainingPointsTest_2()
|
|---|
| 465 | {
|
|---|
| 466 | SphericalPointDistribution SPD(1.);
|
|---|
| 467 | // test with one point, matching trivially
|
|---|
| 468 | {
|
|---|
| 469 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 470 | polygon += std::make_pair(Vector(1.,0.,0.), 1);
|
|---|
| 471 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 472 | expected += Vector(-1.,0.,0.);
|
|---|
| 473 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 474 | SPD.getRemainingPoints(polygon, 2);
|
|---|
| 475 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 476 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 477 | }
|
|---|
| 478 |
|
|---|
| 479 | // test with one point, just a flip of axis
|
|---|
| 480 | {
|
|---|
| 481 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 482 | polygon += std::make_pair( Vector(0.,1.,0.), 1);
|
|---|
| 483 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 484 | expected += Vector(0.,-1.,0.);
|
|---|
| 485 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 486 | SPD.getRemainingPoints(polygon, 2);
|
|---|
| 487 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 488 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 489 | }
|
|---|
| 490 |
|
|---|
| 491 | // test with one point, just a flip to another axis
|
|---|
| 492 | {
|
|---|
| 493 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 494 | polygon += std::make_pair( Vector(0.,0.,-1.), 1);
|
|---|
| 495 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 496 | expected += Vector(0.,0.,1.);
|
|---|
| 497 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 498 | SPD.getRemainingPoints(polygon, 2);
|
|---|
| 499 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 500 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | // test with one point, full rotation
|
|---|
| 504 | {
|
|---|
| 505 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 506 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 507 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 508 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 509 | expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
|
|---|
| 510 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 511 | SPD.getRemainingPoints(polygon, 2);
|
|---|
| 512 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 513 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 514 | }
|
|---|
| 515 | }
|
|---|
| 516 |
|
|---|
| 517 | /** UnitTest for getRemainingPoints() with three points
|
|---|
| 518 | */
|
|---|
| 519 | void SphericalPointDistributionTest::getRemainingPointsTest_3()
|
|---|
| 520 | {
|
|---|
| 521 | SphericalPointDistribution SPD(1.);
|
|---|
| 522 |
|
|---|
| 523 | // test with one point, matching trivially
|
|---|
| 524 | {
|
|---|
| 525 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 526 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 527 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 528 | SPD.get<3>();
|
|---|
| 529 | expected.pop_front(); // remove first point
|
|---|
| 530 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 531 | SPD.getRemainingPoints(polygon, 3);
|
|---|
| 532 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 533 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | // test with one point, just a flip of x and y axis
|
|---|
| 537 | {
|
|---|
| 538 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 539 | polygon += std::make_pair( Vector(0.,1.,0.), 1);
|
|---|
| 540 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 541 | SPD.get<3>();
|
|---|
| 542 | expected.pop_front(); // remove first point
|
|---|
| 543 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 544 | iter != expected.end(); ++iter) {
|
|---|
| 545 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 546 | (*iter)[0] *= -1.;
|
|---|
| 547 | }
|
|---|
| 548 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 549 | SPD.getRemainingPoints(polygon, 3);
|
|---|
| 550 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 551 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | // test with two points, matching trivially
|
|---|
| 555 | {
|
|---|
| 556 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 557 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 558 | polygon += std::make_pair( Vector(-0.5, sqrt(3)*0.5,0.), 1);
|
|---|
| 559 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 560 | SPD.get<3>();
|
|---|
| 561 | expected.pop_front(); // remove first point
|
|---|
| 562 | expected.pop_front(); // remove second point
|
|---|
| 563 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 564 | SPD.getRemainingPoints(polygon, 3);
|
|---|
| 565 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 566 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 567 | // also slightly perturbed
|
|---|
| 568 | const double amplitude = 0.05;
|
|---|
| 569 | perturbPolygon(polygon, amplitude);
|
|---|
| 570 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 571 | }
|
|---|
| 572 |
|
|---|
| 573 | // test with two points, full rotation
|
|---|
| 574 | {
|
|---|
| 575 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 576 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 577 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 578 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI), 1);
|
|---|
| 579 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 580 | SPD.get<3>();
|
|---|
| 581 | expected.pop_front(); // remove first point
|
|---|
| 582 | expected.pop_front(); // remove second point
|
|---|
| 583 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 584 | iter != expected.end(); ++iter)
|
|---|
| 585 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 586 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 587 | SPD.getRemainingPoints(polygon, 3);
|
|---|
| 588 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 589 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 590 | // also slightly perturbed
|
|---|
| 591 | const double amplitude = 0.05;
|
|---|
| 592 | perturbPolygon(polygon, amplitude);
|
|---|
| 593 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|
| 596 | // test with three points, matching trivially
|
|---|
| 597 | {
|
|---|
| 598 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 599 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 600 | polygon += std::make_pair( Vector(-0.5, sqrt(3)*0.5,0.), 1);
|
|---|
| 601 | polygon += std::make_pair( Vector(-0.5, -sqrt(3)*0.5,0.), 1);
|
|---|
| 602 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 603 | SPD.get<3>();
|
|---|
| 604 | SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
|
|---|
| 605 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 606 | SPD.getRemainingPoints(polygon, 3);
|
|---|
| 607 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 608 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 609 | // also slightly perturbed
|
|---|
| 610 | const double amplitude = 0.05;
|
|---|
| 611 | perturbPolygon(polygon, amplitude);
|
|---|
| 612 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 |
|
|---|
| 616 | // test with three points, full rotation
|
|---|
| 617 | {
|
|---|
| 618 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 619 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 620 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 621 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI), 1);
|
|---|
| 622 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-0.5, -sqrt(3)*0.5,0.), 47.6/180*M_PI), 1);
|
|---|
| 623 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 624 | SPD.get<3>();
|
|---|
| 625 | SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
|
|---|
| 626 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 627 | SPD.getRemainingPoints(polygon, 3);
|
|---|
| 628 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 629 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 630 | // also slightly perturbed
|
|---|
| 631 | const double amplitude = 0.05;
|
|---|
| 632 | perturbPolygon(polygon, amplitude);
|
|---|
| 633 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 634 | }
|
|---|
| 635 | }
|
|---|
| 636 |
|
|---|
| 637 | /** UnitTest for getRemainingPoints() with four points
|
|---|
| 638 | */
|
|---|
| 639 | void SphericalPointDistributionTest::getRemainingPointsTest_4()
|
|---|
| 640 | {
|
|---|
| 641 | SphericalPointDistribution SPD(1.);
|
|---|
| 642 |
|
|---|
| 643 | // test with one point, matching trivially
|
|---|
| 644 | {
|
|---|
| 645 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 646 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 647 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 648 | SPD.get<4>();
|
|---|
| 649 | expected.pop_front(); // remove first point
|
|---|
| 650 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 651 | SPD.getRemainingPoints(polygon, 4);
|
|---|
| 652 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 653 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 654 | }
|
|---|
| 655 |
|
|---|
| 656 | // test with one point, just a flip of axis
|
|---|
| 657 | {
|
|---|
| 658 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 659 | polygon += std::make_pair( Vector(0.,1.,0.), 1);
|
|---|
| 660 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 661 | SPD.get<4>();
|
|---|
| 662 | expected.pop_front(); // remove first point
|
|---|
| 663 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 664 | iter != expected.end(); ++iter) {
|
|---|
| 665 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 666 | (*iter)[0] *= -1.;
|
|---|
| 667 | }
|
|---|
| 668 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 669 | SPD.getRemainingPoints(polygon, 4);
|
|---|
| 670 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 671 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 672 | }
|
|---|
| 673 |
|
|---|
| 674 | // test with two points, matching trivially
|
|---|
| 675 | {
|
|---|
| 676 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 677 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 678 | polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1);
|
|---|
| 679 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 680 | SPD.get<4>();
|
|---|
| 681 | expected.pop_front(); // remove first point
|
|---|
| 682 | expected.pop_front(); // remove second point
|
|---|
| 683 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 684 | SPD.getRemainingPoints(polygon, 4);
|
|---|
| 685 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 686 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 687 | // also slightly perturbed
|
|---|
| 688 | const double amplitude = 0.05;
|
|---|
| 689 | perturbPolygon(polygon, amplitude);
|
|---|
| 690 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 691 | }
|
|---|
| 692 |
|
|---|
| 693 | // test with two points, matching trivially, also with slightly perturbed
|
|---|
| 694 | {
|
|---|
| 695 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 696 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 697 | polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1);
|
|---|
| 698 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 699 | SPD.get<4>();
|
|---|
| 700 | expected.pop_front(); // remove first point
|
|---|
| 701 | expected.pop_front(); // remove second point
|
|---|
| 702 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 703 | SPD.getRemainingPoints(polygon, 4);
|
|---|
| 704 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 705 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 706 | // also slightly perturbed
|
|---|
| 707 | const double amplitude = 0.05;
|
|---|
| 708 | perturbPolygon(polygon, amplitude);
|
|---|
| 709 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 710 | }
|
|---|
| 711 |
|
|---|
| 712 | // test with two points, full rotation
|
|---|
| 713 | {
|
|---|
| 714 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 715 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 716 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 717 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1);
|
|---|
| 718 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 719 | SPD.get<4>();
|
|---|
| 720 | expected.pop_front(); // remove first point
|
|---|
| 721 | expected.pop_front(); // remove second point
|
|---|
| 722 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 723 | iter != expected.end(); ++iter)
|
|---|
| 724 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 725 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 726 | SPD.getRemainingPoints(polygon, 4);
|
|---|
| 727 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 728 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 729 | // also slightly perturbed
|
|---|
| 730 | const double amplitude = 0.05;
|
|---|
| 731 | perturbPolygon(polygon, amplitude);
|
|---|
| 732 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 733 | }
|
|---|
| 734 |
|
|---|
| 735 | // test with three points, matching trivially
|
|---|
| 736 | {
|
|---|
| 737 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 738 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 739 | polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1);
|
|---|
| 740 | polygon += std::make_pair( Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 1);
|
|---|
| 741 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 742 | SPD.get<4>();
|
|---|
| 743 | expected.pop_front(); // remove first point
|
|---|
| 744 | expected.pop_front(); // remove second point
|
|---|
| 745 | expected.pop_front(); // remove third point
|
|---|
| 746 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 747 | SPD.getRemainingPoints(polygon, 4);
|
|---|
| 748 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 749 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 750 | // also slightly perturbed
|
|---|
| 751 | const double amplitude = 0.05;
|
|---|
| 752 | perturbPolygon(polygon, amplitude);
|
|---|
| 753 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 754 | }
|
|---|
| 755 |
|
|---|
| 756 | // test with three points, full rotation
|
|---|
| 757 | {
|
|---|
| 758 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 759 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 760 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 761 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1);
|
|---|
| 762 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 47.6/180*M_PI), 1);
|
|---|
| 763 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 764 | SPD.get<4>();
|
|---|
| 765 | expected.pop_front(); // remove first point
|
|---|
| 766 | expected.pop_front(); // remove second point
|
|---|
| 767 | expected.pop_front(); // remove third point
|
|---|
| 768 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 769 | iter != expected.end(); ++iter)
|
|---|
| 770 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 771 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 772 | SPD.getRemainingPoints(polygon, 4);
|
|---|
| 773 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 774 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 775 | // also slightly perturbed
|
|---|
| 776 | const double amplitude = 0.05;
|
|---|
| 777 | perturbPolygon(polygon, amplitude);
|
|---|
| 778 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 779 | }
|
|---|
| 780 | }
|
|---|
| 781 |
|
|---|
| 782 | /** UnitTest for getRemainingPoints() with four points and weights
|
|---|
| 783 | * not all equal to one.
|
|---|
| 784 | */
|
|---|
| 785 | void SphericalPointDistributionTest::getRemainingPointsTest_multiple()
|
|---|
| 786 | {
|
|---|
| 787 | SphericalPointDistribution SPD(1.);
|
|---|
| 788 |
|
|---|
| 789 | // test with four points: one point having weight of two
|
|---|
| 790 | {
|
|---|
| 791 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 792 | polygon += std::make_pair( Vector(1.,0.,0.), 2);
|
|---|
| 793 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 794 | SPD.get<4>();
|
|---|
| 795 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 796 | expected += Vector(-0.5773502691896,-5.551115123126e-17,0.8164965809277);
|
|---|
| 797 | expected += Vector(-0.5773502691896,-5.551115123126e-17,-0.8164965809277);
|
|---|
| 798 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 799 | SPD.getRemainingPoints(polygon, 4);
|
|---|
| 800 | // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
|
|---|
| 801 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 802 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 803 | }
|
|---|
| 804 |
|
|---|
| 805 | // test with five points: one point having weight of two
|
|---|
| 806 | {
|
|---|
| 807 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 808 | polygon += std::make_pair( Vector(1.,0.,0.), 2);
|
|---|
| 809 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 810 | SPD.get<5>();
|
|---|
| 811 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 812 | expected += Vector(-0.7071067811865,0.7071067811865,0);
|
|---|
| 813 | expected += Vector(-0.3535533905933,-0.3535533905933,0.8660254037844);
|
|---|
| 814 | expected += Vector(-0.3535533905933,-0.3535533905933,-0.8660254037844);
|
|---|
| 815 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 816 | SPD.getRemainingPoints(polygon, 5);
|
|---|
| 817 | std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
|
|---|
| 818 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 819 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 820 | }
|
|---|
| 821 |
|
|---|
| 822 |
|
|---|
| 823 | // test with five points: one point having weight of two, one weight of one
|
|---|
| 824 | {
|
|---|
| 825 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 826 | polygon += std::make_pair( Vector(M_SQRT1_2,M_SQRT1_2,0.), 2);
|
|---|
| 827 | polygon += std::make_pair( Vector(-1.,0.,0.), 1);
|
|---|
| 828 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 829 | SPD.get<5>();
|
|---|
| 830 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 831 | expected += Vector(0.3535533786708,-0.3535533955317,-0.8660254066357);
|
|---|
| 832 | expected += Vector(0.3535534025157,-0.3535533856548,0.8660254009332);
|
|---|
| 833 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 834 | SPD.getRemainingPoints(polygon, 5);
|
|---|
| 835 | // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
|
|---|
| 836 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 837 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 838 | }
|
|---|
| 839 |
|
|---|
| 840 | // test with six points: two points each having weight of two
|
|---|
| 841 | {
|
|---|
| 842 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 843 | polygon += std::make_pair( Vector(M_SQRT1_2,-M_SQRT1_2,0.), 2);
|
|---|
| 844 | polygon += std::make_pair( Vector(-M_SQRT1_2,M_SQRT1_2,0.), 2);
|
|---|
| 845 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 846 | SPD.get<6>();
|
|---|
| 847 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 848 | expected += Vector(0.,0.,1.);
|
|---|
| 849 | expected += Vector(0.,0.,-1.);
|
|---|
| 850 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 851 | SPD.getRemainingPoints(polygon, 6);
|
|---|
| 852 | // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
|
|---|
| 853 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 854 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 855 | }
|
|---|
| 856 | }
|
|---|
| 857 |
|
|---|
| 858 | /** UnitTest for getRemainingPoints() with five points
|
|---|
| 859 | */
|
|---|
| 860 | void SphericalPointDistributionTest::getRemainingPointsTest_5()
|
|---|
| 861 | {
|
|---|
| 862 | SphericalPointDistribution SPD(1.);
|
|---|
| 863 |
|
|---|
| 864 | // test with one point, matching trivially
|
|---|
| 865 | {
|
|---|
| 866 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 867 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 868 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 869 | SPD.get<5>();
|
|---|
| 870 | expected.pop_front(); // remove first point
|
|---|
| 871 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 872 | SPD.getRemainingPoints(polygon, 5);
|
|---|
| 873 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 874 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 875 | }
|
|---|
| 876 |
|
|---|
| 877 | // test with one point, just a flip of axis
|
|---|
| 878 | {
|
|---|
| 879 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 880 | polygon += std::make_pair( Vector(0.,1.,0.), 1);
|
|---|
| 881 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 882 | SPD.get<5>();
|
|---|
| 883 | expected.pop_front(); // remove first point
|
|---|
| 884 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 885 | iter != expected.end(); ++iter) {
|
|---|
| 886 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 887 | (*iter)[0] *= -1.;
|
|---|
| 888 | }
|
|---|
| 889 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 890 | SPD.getRemainingPoints(polygon, 5);
|
|---|
| 891 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 892 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 893 | }
|
|---|
| 894 |
|
|---|
| 895 | // test with two points, matching trivially
|
|---|
| 896 | {
|
|---|
| 897 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 898 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 899 | polygon += std::make_pair( Vector(-1.,0.,0.), 1);
|
|---|
| 900 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 901 | SPD.get<5>();
|
|---|
| 902 | expected.pop_front(); // remove first point
|
|---|
| 903 | expected.pop_front(); // remove second point
|
|---|
| 904 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 905 | SPD.getRemainingPoints(polygon, 5);
|
|---|
| 906 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 907 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 908 | // also slightly perturbed
|
|---|
| 909 | const double amplitude = 0.05;
|
|---|
| 910 | perturbPolygon(polygon, amplitude);
|
|---|
| 911 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 912 | }
|
|---|
| 913 |
|
|---|
| 914 | // test with two points, full rotation
|
|---|
| 915 | {
|
|---|
| 916 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 917 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 918 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180.*M_PI), 1);
|
|---|
| 919 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180.*M_PI), 1);
|
|---|
| 920 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 921 | SPD.get<5>();
|
|---|
| 922 | expected.pop_front(); // remove first point
|
|---|
| 923 | expected.pop_front(); // remove second point
|
|---|
| 924 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 925 | iter != expected.end(); ++iter)
|
|---|
| 926 | *iter = RotationAxis.rotateVector(*iter, 47.6/180.*M_PI);
|
|---|
| 927 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 928 | SPD.getRemainingPoints(polygon, 5);
|
|---|
| 929 | // the three remaining points sit on a plane that may be rotated arbitrarily
|
|---|
| 930 | // so we cannot simply check for equality between expected and remaining
|
|---|
| 931 | // hence, we just check that they are orthogonal to the first two points
|
|---|
| 932 | CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() );
|
|---|
| 933 | for (SphericalPointDistribution::WeightedPolygon_t::const_iterator fixiter = polygon.begin();
|
|---|
| 934 | fixiter != polygon.end(); ++fixiter) {
|
|---|
| 935 | for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin();
|
|---|
| 936 | iter != remaining.end(); ++iter) {
|
|---|
| 937 | CPPUNIT_ASSERT( (fixiter->first).IsNormalTo(*iter) );
|
|---|
| 938 | }
|
|---|
| 939 | }
|
|---|
| 940 | }
|
|---|
| 941 |
|
|---|
| 942 | // test with three points, matching trivially
|
|---|
| 943 | {
|
|---|
| 944 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 945 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 946 | polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
|
|---|
| 947 | polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
|
|---|
| 948 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 949 | SPD.get<5>();
|
|---|
| 950 | expected.pop_front(); // remove first point
|
|---|
| 951 | expected.pop_front(); // remove second point
|
|---|
| 952 | expected.pop_front(); // remove third point
|
|---|
| 953 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 954 | SPD.getRemainingPoints(polygon, 5);
|
|---|
| 955 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 956 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 957 | // also slightly perturbed
|
|---|
| 958 | const double amplitude = 0.05;
|
|---|
| 959 | perturbPolygon(polygon, amplitude);
|
|---|
| 960 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 961 | }
|
|---|
| 962 |
|
|---|
| 963 | // test with three points, full rotation
|
|---|
| 964 | {
|
|---|
| 965 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 966 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 967 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 968 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
|
|---|
| 969 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1);
|
|---|
| 970 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 971 | SPD.get<5>();
|
|---|
| 972 | expected.pop_front(); // remove first point
|
|---|
| 973 | expected.pop_front(); // remove second point
|
|---|
| 974 | expected.pop_front(); // remove third point
|
|---|
| 975 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 976 | iter != expected.end(); ++iter)
|
|---|
| 977 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 978 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 979 | SPD.getRemainingPoints(polygon, 5);
|
|---|
| 980 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 981 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 982 | // also slightly perturbed
|
|---|
| 983 | const double amplitude = 0.05;
|
|---|
| 984 | perturbPolygon(polygon, amplitude);
|
|---|
| 985 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 986 | }
|
|---|
| 987 | }
|
|---|
| 988 |
|
|---|
| 989 | /** UnitTest for getRemainingPoints() with six points
|
|---|
| 990 | */
|
|---|
| 991 | void SphericalPointDistributionTest::getRemainingPointsTest_6()
|
|---|
| 992 | {
|
|---|
| 993 | SphericalPointDistribution SPD(1.);
|
|---|
| 994 |
|
|---|
| 995 | // test with one point, matching trivially
|
|---|
| 996 | {
|
|---|
| 997 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 998 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 999 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1000 | SPD.get<6>();
|
|---|
| 1001 | expected.pop_front(); // remove first point
|
|---|
| 1002 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1003 | SPD.getRemainingPoints(polygon, 6);
|
|---|
| 1004 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1005 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1006 | }
|
|---|
| 1007 |
|
|---|
| 1008 | // test with one point, just a flip of axis
|
|---|
| 1009 | {
|
|---|
| 1010 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1011 | polygon += std::make_pair( Vector(0.,1.,0.), 1);
|
|---|
| 1012 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1013 | SPD.get<6>();
|
|---|
| 1014 | expected.pop_front(); // remove first point
|
|---|
| 1015 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1016 | iter != expected.end(); ++iter) {
|
|---|
| 1017 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 1018 | (*iter)[0] *= -1.;
|
|---|
| 1019 | }
|
|---|
| 1020 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1021 | SPD.getRemainingPoints(polygon, 6);
|
|---|
| 1022 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1023 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1024 | }
|
|---|
| 1025 |
|
|---|
| 1026 | // test with two points, matching trivially
|
|---|
| 1027 | {
|
|---|
| 1028 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1029 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 1030 | polygon += std::make_pair( Vector(-1.,0.,0.), 1);
|
|---|
| 1031 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1032 | SPD.get<6>();
|
|---|
| 1033 | expected.pop_front(); // remove first point
|
|---|
| 1034 | expected.pop_front(); // remove second spoint
|
|---|
| 1035 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1036 | SPD.getRemainingPoints(polygon, 6);
|
|---|
| 1037 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1038 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1039 | // also slightly perturbed
|
|---|
| 1040 | const double amplitude = 0.05;
|
|---|
| 1041 | perturbPolygon(polygon, amplitude);
|
|---|
| 1042 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1043 | }
|
|---|
| 1044 |
|
|---|
| 1045 | // test with two points, full rotation
|
|---|
| 1046 | {
|
|---|
| 1047 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 1048 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1049 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1050 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1051 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1052 | SPD.get<6>();
|
|---|
| 1053 | expected.pop_front(); // remove first point
|
|---|
| 1054 | expected.pop_front(); // remove second spoint
|
|---|
| 1055 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1056 | iter != expected.end(); ++iter)
|
|---|
| 1057 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 1058 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1059 | SPD.getRemainingPoints(polygon, 6);
|
|---|
| 1060 | // the four remaining points sit on a plane that may have been rotated arbitrarily
|
|---|
| 1061 | // so we cannot simply check for equality between expected and remaining
|
|---|
| 1062 | // hence, we just check that they are orthogonal to the first two points
|
|---|
| 1063 | CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() );
|
|---|
| 1064 | for (SphericalPointDistribution::WeightedPolygon_t::const_iterator fixiter = polygon.begin();
|
|---|
| 1065 | fixiter != polygon.end(); ++fixiter) {
|
|---|
| 1066 | for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin();
|
|---|
| 1067 | iter != remaining.end(); ++iter) {
|
|---|
| 1068 | CPPUNIT_ASSERT( (fixiter->first).IsNormalTo(*iter) );
|
|---|
| 1069 | }
|
|---|
| 1070 | }
|
|---|
| 1071 | }
|
|---|
| 1072 |
|
|---|
| 1073 | // test with three points, matching trivially
|
|---|
| 1074 | {
|
|---|
| 1075 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1076 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 1077 | polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
|
|---|
| 1078 | polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
|
|---|
| 1079 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1080 | SPD.get<6>();
|
|---|
| 1081 | expected.pop_front(); // remove first point
|
|---|
| 1082 | expected.pop_front(); // remove second point
|
|---|
| 1083 | expected.pop_front(); // remove third point
|
|---|
| 1084 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1085 | SPD.getRemainingPoints(polygon, 6);
|
|---|
| 1086 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1087 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1088 | // also slightly perturbed
|
|---|
| 1089 | const double amplitude = 0.05;
|
|---|
| 1090 | perturbPolygon(polygon, amplitude);
|
|---|
| 1091 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1092 | }
|
|---|
| 1093 |
|
|---|
| 1094 | // test with three points, full rotation
|
|---|
| 1095 | {
|
|---|
| 1096 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 1097 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1098 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1099 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
|
|---|
| 1100 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1);
|
|---|
| 1101 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1102 | SPD.get<6>();
|
|---|
| 1103 | expected.pop_front(); // remove first point
|
|---|
| 1104 | expected.pop_front(); // remove second point
|
|---|
| 1105 | expected.pop_front(); // remove third point
|
|---|
| 1106 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1107 | iter != expected.end(); ++iter)
|
|---|
| 1108 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 1109 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1110 | SPD.getRemainingPoints(polygon, 6);
|
|---|
| 1111 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1112 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1113 | // also slightly perturbed
|
|---|
| 1114 | const double amplitude = 0.05;
|
|---|
| 1115 | perturbPolygon(polygon, amplitude);
|
|---|
| 1116 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1117 | }
|
|---|
| 1118 | }
|
|---|
| 1119 |
|
|---|
| 1120 | /** UnitTest for getRemainingPoints() with seven points
|
|---|
| 1121 | */
|
|---|
| 1122 | void SphericalPointDistributionTest::getRemainingPointsTest_7()
|
|---|
| 1123 | {
|
|---|
| 1124 | SphericalPointDistribution SPD(1.);
|
|---|
| 1125 |
|
|---|
| 1126 | // test with one point, matching trivially
|
|---|
| 1127 | {
|
|---|
| 1128 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1129 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 1130 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1131 | SPD.get<7>();
|
|---|
| 1132 | expected.pop_front(); // remove first point
|
|---|
| 1133 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1134 | SPD.getRemainingPoints(polygon, 7);
|
|---|
| 1135 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1136 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1137 | }
|
|---|
| 1138 |
|
|---|
| 1139 | // test with one point, just a flip of axis
|
|---|
| 1140 | {
|
|---|
| 1141 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1142 | polygon += std::make_pair( Vector(0.,1.,0.), 1);
|
|---|
| 1143 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1144 | SPD.get<7>();
|
|---|
| 1145 | expected.pop_front(); // remove first point
|
|---|
| 1146 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1147 | iter != expected.end(); ++iter) {
|
|---|
| 1148 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 1149 | (*iter)[0] *= -1.;
|
|---|
| 1150 | }
|
|---|
| 1151 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1152 | SPD.getRemainingPoints(polygon, 7);
|
|---|
| 1153 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1154 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1155 | }
|
|---|
| 1156 |
|
|---|
| 1157 | // test with two points, matching trivially
|
|---|
| 1158 | {
|
|---|
| 1159 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1160 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 1161 | polygon += std::make_pair( Vector(-1.,0.,0.), 1);
|
|---|
| 1162 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1163 | SPD.get<7>();
|
|---|
| 1164 | expected.pop_front(); // remove first point
|
|---|
| 1165 | expected.pop_front(); // remove second point
|
|---|
| 1166 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1167 | SPD.getRemainingPoints(polygon, 7);
|
|---|
| 1168 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1169 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1170 | // also slightly perturbed
|
|---|
| 1171 | const double amplitude = 0.05;
|
|---|
| 1172 | perturbPolygon(polygon, amplitude);
|
|---|
| 1173 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1174 | }
|
|---|
| 1175 |
|
|---|
| 1176 | // test with two points, full rotation
|
|---|
| 1177 | {
|
|---|
| 1178 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 1179 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1180 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1181 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1182 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1183 | SPD.get<7>();
|
|---|
| 1184 | expected.pop_front(); // remove first point
|
|---|
| 1185 | expected.pop_front(); // remove second point
|
|---|
| 1186 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1187 | iter != expected.end(); ++iter)
|
|---|
| 1188 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 1189 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1190 | SPD.getRemainingPoints(polygon, 7);
|
|---|
| 1191 | // the five remaining points sit on a plane that may have been rotated arbitrarily
|
|---|
| 1192 | // so we cannot simply check for equality between expected and remaining
|
|---|
| 1193 | // hence, we just check that they are orthogonal to the first two points
|
|---|
| 1194 | CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() );
|
|---|
| 1195 | for (SphericalPointDistribution::WeightedPolygon_t::const_iterator fixiter = polygon.begin();
|
|---|
| 1196 | fixiter != polygon.end(); ++fixiter) {
|
|---|
| 1197 | for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin();
|
|---|
| 1198 | iter != remaining.end(); ++iter) {
|
|---|
| 1199 | CPPUNIT_ASSERT( (fixiter->first).IsNormalTo(*iter) );
|
|---|
| 1200 | }
|
|---|
| 1201 | }
|
|---|
| 1202 | }
|
|---|
| 1203 |
|
|---|
| 1204 | // test with three points, matching trivially
|
|---|
| 1205 | {
|
|---|
| 1206 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1207 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 1208 | polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
|
|---|
| 1209 | polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
|
|---|
| 1210 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1211 | SPD.get<7>();
|
|---|
| 1212 | expected.pop_front(); // remove first point
|
|---|
| 1213 | expected.pop_front(); // remove second point
|
|---|
| 1214 | expected.pop_front(); // remove third point
|
|---|
| 1215 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1216 | SPD.getRemainingPoints(polygon, 7);
|
|---|
| 1217 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1218 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1219 | // also slightly perturbed
|
|---|
| 1220 | const double amplitude = 0.05;
|
|---|
| 1221 | perturbPolygon(polygon, amplitude);
|
|---|
| 1222 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1223 | }
|
|---|
| 1224 |
|
|---|
| 1225 | // test with three points, full rotation
|
|---|
| 1226 | {
|
|---|
| 1227 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 1228 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1229 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1230 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
|
|---|
| 1231 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1);
|
|---|
| 1232 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1233 | SPD.get<7>();
|
|---|
| 1234 | expected.pop_front(); // remove first point
|
|---|
| 1235 | expected.pop_front(); // remove second point
|
|---|
| 1236 | expected.pop_front(); // remove third point
|
|---|
| 1237 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1238 | iter != expected.end(); ++iter)
|
|---|
| 1239 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 1240 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1241 | SPD.getRemainingPoints(polygon, 7);
|
|---|
| 1242 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1243 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1244 | // also slightly perturbed
|
|---|
| 1245 | const double amplitude = 0.05;
|
|---|
| 1246 | perturbPolygon(polygon, amplitude);
|
|---|
| 1247 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1248 | }
|
|---|
| 1249 | }
|
|---|
| 1250 |
|
|---|
| 1251 | /** UnitTest for getRemainingPoints() with eight points
|
|---|
| 1252 | */
|
|---|
| 1253 | void SphericalPointDistributionTest::getRemainingPointsTest_8()
|
|---|
| 1254 | {
|
|---|
| 1255 | SphericalPointDistribution SPD(1.);
|
|---|
| 1256 |
|
|---|
| 1257 | // test with one point, matching trivially
|
|---|
| 1258 | {
|
|---|
| 1259 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1260 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 1261 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1262 | SPD.get<8>();
|
|---|
| 1263 | expected.pop_front(); // remove first point
|
|---|
| 1264 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1265 | SPD.getRemainingPoints(polygon, 8);
|
|---|
| 1266 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1267 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1268 | }
|
|---|
| 1269 |
|
|---|
| 1270 | // test with one point, just a flip of axis
|
|---|
| 1271 | {
|
|---|
| 1272 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1273 | polygon += std::make_pair( Vector(0.,1.,0.), 1);
|
|---|
| 1274 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1275 | SPD.get<8>();
|
|---|
| 1276 | expected.pop_front(); // remove first point
|
|---|
| 1277 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1278 | iter != expected.end(); ++iter) {
|
|---|
| 1279 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 1280 | (*iter)[0] *= -1.;
|
|---|
| 1281 | }
|
|---|
| 1282 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1283 | SPD.getRemainingPoints(polygon, 8);
|
|---|
| 1284 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1285 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1286 | }
|
|---|
| 1287 |
|
|---|
| 1288 | // test with two points, matching trivially
|
|---|
| 1289 | {
|
|---|
| 1290 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1291 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 1292 | polygon += std::make_pair( Vector(-1.,0.,0.), 1);
|
|---|
| 1293 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1294 | SPD.get<8>();
|
|---|
| 1295 | expected.pop_front(); // remove first point
|
|---|
| 1296 | expected.pop_front(); // remove second point
|
|---|
| 1297 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1298 | SPD.getRemainingPoints(polygon, 8);
|
|---|
| 1299 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1300 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1301 | // also slightly perturbed
|
|---|
| 1302 | const double amplitude = 0.05;
|
|---|
| 1303 | perturbPolygon(polygon, amplitude);
|
|---|
| 1304 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1305 | }
|
|---|
| 1306 |
|
|---|
| 1307 | // test with two points, full rotation
|
|---|
| 1308 | {
|
|---|
| 1309 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 1310 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1311 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1312 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1313 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1314 | SPD.get<8>();
|
|---|
| 1315 | expected.pop_front(); // remove first point
|
|---|
| 1316 | expected.pop_front(); // remove second point
|
|---|
| 1317 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1318 | iter != expected.end(); ++iter)
|
|---|
| 1319 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 1320 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1321 | SPD.getRemainingPoints(polygon, 8);
|
|---|
| 1322 | // the six remaining points sit on two planes that may have been rotated arbitrarily
|
|---|
| 1323 | // so we cannot simply check for equality between expected and remaining
|
|---|
| 1324 | // hence, we just check that they are orthogonal to the first two points
|
|---|
| 1325 | CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() );
|
|---|
| 1326 | for (SphericalPointDistribution::WeightedPolygon_t::const_iterator fixiter = polygon.begin();
|
|---|
| 1327 | fixiter != polygon.end(); ++fixiter) {
|
|---|
| 1328 | SphericalPointDistribution::Polygon_t::const_iterator expectiter = expected.begin();
|
|---|
| 1329 | SphericalPointDistribution::Polygon_t::const_iterator remainiter = remaining.begin();
|
|---|
| 1330 | for (;remainiter != remaining.end(); ++expectiter, ++remainiter) {
|
|---|
| 1331 | // check that points in expected/remaining have same angle to the given ones
|
|---|
| 1332 | // CPPUNIT_ASSERT_EQUAL( (*expectiter).Angle(*fixiter), (*remainiter).Angle(*fixiter) );
|
|---|
| 1333 | CPPUNIT_ASSERT( fabs( (*expectiter).Angle(fixiter->first) - (*remainiter).Angle(fixiter->first) )
|
|---|
| 1334 | < std::numeric_limits<double>::epsilon()*1e4 );
|
|---|
| 1335 | }
|
|---|
| 1336 | }
|
|---|
| 1337 | }
|
|---|
| 1338 |
|
|---|
| 1339 | // test with three points, matching trivially
|
|---|
| 1340 | {
|
|---|
| 1341 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1342 | polygon += std::make_pair( Vector(1.,0.,0.), 1);
|
|---|
| 1343 | polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
|
|---|
| 1344 | polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 1);
|
|---|
| 1345 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1346 | SPD.get<8>();
|
|---|
| 1347 | expected.pop_front(); // remove first point
|
|---|
| 1348 | expected.pop_front(); // remove second point
|
|---|
| 1349 | expected.pop_front(); // remove third point
|
|---|
| 1350 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1351 | SPD.getRemainingPoints(polygon, 8);
|
|---|
| 1352 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1353 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1354 | // also slightly perturbed
|
|---|
| 1355 | const double amplitude = 0.05;
|
|---|
| 1356 | perturbPolygon(polygon, amplitude);
|
|---|
| 1357 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1358 | }
|
|---|
| 1359 |
|
|---|
| 1360 | // test with three points, full rotation
|
|---|
| 1361 | {
|
|---|
| 1362 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 1363 | SphericalPointDistribution::WeightedPolygon_t polygon;
|
|---|
| 1364 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
|
|---|
| 1365 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
|
|---|
| 1366 | polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 47.6/180*M_PI), 1);
|
|---|
| 1367 | SphericalPointDistribution::Polygon_t expected =
|
|---|
| 1368 | SPD.get<8>();
|
|---|
| 1369 | expected.pop_front(); // remove first point
|
|---|
| 1370 | expected.pop_front(); // remove second point
|
|---|
| 1371 | expected.pop_front(); // remove third point
|
|---|
| 1372 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1373 | iter != expected.end(); ++iter)
|
|---|
| 1374 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 1375 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1376 | SPD.getRemainingPoints(polygon, 8);
|
|---|
| 1377 | // CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1378 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
|
|---|
| 1379 | // also slightly perturbed
|
|---|
| 1380 | const double amplitude = 0.05;
|
|---|
| 1381 | perturbPolygon(polygon, amplitude);
|
|---|
| 1382 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1383 | }
|
|---|
| 1384 | }
|
|---|