| 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 <boost/assign.hpp>
|
|---|
| 48 | #include <boost/math/quaternion.hpp>
|
|---|
| 49 |
|
|---|
| 50 | #include "CodePatterns/Assert.hpp"
|
|---|
| 51 | #include "CodePatterns/Log.hpp"
|
|---|
| 52 |
|
|---|
| 53 | #include "LinearAlgebra/Line.hpp"
|
|---|
| 54 |
|
|---|
| 55 | #include "Fragmentation/Exporters/SphericalPointDistribution.hpp"
|
|---|
| 56 |
|
|---|
| 57 | #include "LinearAlgebra/Line.hpp"
|
|---|
| 58 |
|
|---|
| 59 | #ifdef HAVE_TESTRUNNER
|
|---|
| 60 | #include "UnitTestMain.hpp"
|
|---|
| 61 | #endif /*HAVE_TESTRUNNER*/
|
|---|
| 62 |
|
|---|
| 63 | using namespace boost::assign;
|
|---|
| 64 |
|
|---|
| 65 | /********************************************** Test classes **************************************/
|
|---|
| 66 |
|
|---|
| 67 | // Registers the fixture into the 'registry'
|
|---|
| 68 | CPPUNIT_TEST_SUITE_REGISTRATION( SphericalPointDistributionTest );
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | void SphericalPointDistributionTest::setUp()
|
|---|
| 72 | {
|
|---|
| 73 | // failing asserts should be thrown
|
|---|
| 74 | ASSERT_DO(Assert::Throw);
|
|---|
| 75 |
|
|---|
| 76 | setVerbosity(6);
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | void SphericalPointDistributionTest::tearDown()
|
|---|
| 81 | {
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | /** UnitTest for matchSphericalPointDistributions() with two points
|
|---|
| 86 | */
|
|---|
| 87 | void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2()
|
|---|
| 88 | {
|
|---|
| 89 | SphericalPointDistribution SPD(1.);
|
|---|
| 90 | // test with one point, matching trivially
|
|---|
| 91 | {
|
|---|
| 92 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 93 | polygon += Vector(1.,0.,0.);
|
|---|
| 94 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 95 | SPD.get<2>();
|
|---|
| 96 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 97 | expected += Vector(-1.,0.,0.);
|
|---|
| 98 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 99 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 100 | polygon,
|
|---|
| 101 | newpolygon);
|
|---|
| 102 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | // test with one point, just a flip of axis
|
|---|
| 106 | {
|
|---|
| 107 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 108 | polygon += Vector(0.,1.,0.);
|
|---|
| 109 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 110 | SPD.get<2>();
|
|---|
| 111 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 112 | expected += Vector(0.,-1.,0.);
|
|---|
| 113 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 114 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 115 | polygon,
|
|---|
| 116 | newpolygon);
|
|---|
| 117 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | // test with one point, just a flip to another axis
|
|---|
| 121 | {
|
|---|
| 122 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 123 | polygon += Vector(0.,0.,-1.);
|
|---|
| 124 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 125 | SPD.get<2>();
|
|---|
| 126 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 127 | expected += Vector(0.,0.,1.);
|
|---|
| 128 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 129 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 130 | polygon,
|
|---|
| 131 | newpolygon);
|
|---|
| 132 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | // test with one point, full rotation
|
|---|
| 136 | {
|
|---|
| 137 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 138 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 139 | polygon += RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI);
|
|---|
| 140 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 141 | SPD.get<2>();
|
|---|
| 142 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 143 | expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
|
|---|
| 144 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 145 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 146 | polygon,
|
|---|
| 147 | newpolygon);
|
|---|
| 148 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 149 | }
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | void perturbPolygon(
|
|---|
| 153 | SphericalPointDistribution::Polygon_t &_polygon,
|
|---|
| 154 | double _amplitude
|
|---|
| 155 | )
|
|---|
| 156 | {
|
|---|
| 157 | for (SphericalPointDistribution::Polygon_t::iterator iter = _polygon.begin();
|
|---|
| 158 | iter != _polygon.end(); ++iter) {
|
|---|
| 159 | Vector perturber;
|
|---|
| 160 | perturber.GetOneNormalVector((*iter));
|
|---|
| 161 | perturber.Scale(_amplitude);
|
|---|
| 162 | *iter = *iter + perturber;
|
|---|
| 163 | (*iter).Normalize();
|
|---|
| 164 | }
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | static
|
|---|
| 168 | bool areEqualToWithinBounds(
|
|---|
| 169 | const SphericalPointDistribution::Polygon_t &_polygon,
|
|---|
| 170 | const SphericalPointDistribution::Polygon_t &_otherpolygon,
|
|---|
| 171 | double _amplitude
|
|---|
| 172 | )
|
|---|
| 173 | {
|
|---|
| 174 | // same size?
|
|---|
| 175 | if (_polygon.size() != _otherpolygon.size())
|
|---|
| 176 | return false;
|
|---|
| 177 | // same points ? We just check witrh trivial mapping, nothing fancy ...
|
|---|
| 178 | bool status = true;
|
|---|
| 179 | SphericalPointDistribution::Polygon_t::const_iterator iter = _polygon.begin();
|
|---|
| 180 | SphericalPointDistribution::Polygon_t::const_iterator otheriter = _otherpolygon.begin();
|
|---|
| 181 | for (; iter != _polygon.end(); ++iter, ++otheriter) {
|
|---|
| 182 | status &= (*iter - *otheriter).Norm() < _amplitude;
|
|---|
| 183 | }
|
|---|
| 184 | return status;
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | /** UnitTest for areEqualToWithinBounds()
|
|---|
| 188 | */
|
|---|
| 189 | void SphericalPointDistributionTest::areEqualToWithinBoundsTest()
|
|---|
| 190 | {
|
|---|
| 191 | // test with no points
|
|---|
| 192 | {
|
|---|
| 193 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 194 | SphericalPointDistribution::Polygon_t expected = polygon;
|
|---|
| 195 | CPPUNIT_ASSERT( areEqualToWithinBounds(polygon, expected, std::numeric_limits<double>::epsilon()*1e2) );
|
|---|
| 196 | }
|
|---|
| 197 | // test with one point
|
|---|
| 198 | {
|
|---|
| 199 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 200 | polygon += Vector(1.,0.,0.);
|
|---|
| 201 | SphericalPointDistribution::Polygon_t expected = polygon;
|
|---|
| 202 | CPPUNIT_ASSERT( areEqualToWithinBounds(polygon, expected, std::numeric_limits<double>::epsilon()*1e2) );
|
|---|
| 203 | }
|
|---|
| 204 | // test with two points
|
|---|
| 205 | {
|
|---|
| 206 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 207 | polygon += Vector(1.,0.,0.);
|
|---|
| 208 | polygon += Vector(0.,1.,0.);
|
|---|
| 209 | SphericalPointDistribution::Polygon_t expected = polygon;
|
|---|
| 210 | CPPUNIT_ASSERT( areEqualToWithinBounds(polygon, expected, std::numeric_limits<double>::epsilon()*1e2) );
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | // test with two points in different order: THIS GOES WRONG: We only check trivially
|
|---|
| 214 | {
|
|---|
| 215 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 216 | polygon += Vector(1.,0.,0.);
|
|---|
| 217 | polygon += Vector(0.,1.,0.);
|
|---|
| 218 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 219 | expected += Vector(0.,1.,0.);
|
|---|
| 220 | expected += Vector(1.,0.,0.);
|
|---|
| 221 | CPPUNIT_ASSERT( !areEqualToWithinBounds(polygon, expected, std::numeric_limits<double>::epsilon()*1e2) );
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | // test with two different points
|
|---|
| 225 | {
|
|---|
| 226 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 227 | polygon += Vector(1.,0.,0.);
|
|---|
| 228 | polygon += Vector(0.,1.,0.);
|
|---|
| 229 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 230 | expected += Vector(1.01,0.,0.);
|
|---|
| 231 | expected += Vector(0.,1.,0.);
|
|---|
| 232 | CPPUNIT_ASSERT( areEqualToWithinBounds(polygon, expected, 0.05) );
|
|---|
| 233 | CPPUNIT_ASSERT( !areEqualToWithinBounds(polygon, expected, 0.005) );
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | // test with different number of points
|
|---|
| 237 | {
|
|---|
| 238 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 239 | polygon += Vector(1.,0.,0.);
|
|---|
| 240 | polygon += Vector(0.,1.,0.);
|
|---|
| 241 | SphericalPointDistribution::Polygon_t expected;
|
|---|
| 242 | expected += Vector(0.,1.,0.);
|
|---|
| 243 | CPPUNIT_ASSERT( !areEqualToWithinBounds(polygon, expected, 0.05) );
|
|---|
| 244 | }
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 | /** UnitTest for matchSphericalPointDistributions() with three points
|
|---|
| 249 | */
|
|---|
| 250 | void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_3()
|
|---|
| 251 | {
|
|---|
| 252 | SphericalPointDistribution SPD(1.);
|
|---|
| 253 |
|
|---|
| 254 | // test with one point, matching trivially
|
|---|
| 255 | {
|
|---|
| 256 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 257 | polygon += Vector(1.,0.,0.);
|
|---|
| 258 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 259 | SPD.get<3>();
|
|---|
| 260 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 261 | expected.pop_front(); // remove first point
|
|---|
| 262 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 263 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 264 | polygon,
|
|---|
| 265 | newpolygon);
|
|---|
| 266 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | // test with one point, just a flip of x and y axis
|
|---|
| 270 | {
|
|---|
| 271 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 272 | polygon += Vector(0.,1.,0.);
|
|---|
| 273 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 274 | SPD.get<3>();
|
|---|
| 275 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 276 | expected.pop_front(); // remove first point
|
|---|
| 277 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 278 | iter != expected.end(); ++iter) {
|
|---|
| 279 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 280 | (*iter)[0] *= -1.;
|
|---|
| 281 | }
|
|---|
| 282 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 283 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 284 | polygon,
|
|---|
| 285 | newpolygon);
|
|---|
| 286 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | // test with two points, matching trivially
|
|---|
| 290 | {
|
|---|
| 291 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 292 | polygon += Vector(1.,0.,0.), Vector(-0.5, sqrt(3)*0.5,0.);
|
|---|
| 293 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 294 | SPD.get<3>();
|
|---|
| 295 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 296 | expected.pop_front(); // remove first point
|
|---|
| 297 | expected.pop_front(); // remove second point
|
|---|
| 298 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 299 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 300 | polygon,
|
|---|
| 301 | newpolygon);
|
|---|
| 302 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 303 | // also slightly perturbed
|
|---|
| 304 | const double amplitude = 0.05;
|
|---|
| 305 | perturbPolygon(polygon, amplitude);
|
|---|
| 306 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 | // test with two points, full rotation
|
|---|
| 310 | {
|
|---|
| 311 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 312 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 313 | polygon +=
|
|---|
| 314 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 315 | RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI);
|
|---|
| 316 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 317 | SPD.get<3>();
|
|---|
| 318 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 319 | expected.pop_front(); // remove first point
|
|---|
| 320 | expected.pop_front(); // remove second point
|
|---|
| 321 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 322 | iter != expected.end(); ++iter)
|
|---|
| 323 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 324 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 325 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 326 | polygon,
|
|---|
| 327 | newpolygon);
|
|---|
| 328 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 329 | // also slightly perturbed
|
|---|
| 330 | const double amplitude = 0.05;
|
|---|
| 331 | perturbPolygon(polygon, amplitude);
|
|---|
| 332 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | // test with three points, matching trivially
|
|---|
| 336 | {
|
|---|
| 337 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 338 | polygon += Vector(1.,0.,0.), Vector(-0.5, sqrt(3)*0.5,0.), Vector(-0.5, -sqrt(3)*0.5,0.);
|
|---|
| 339 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 340 | SPD.get<3>();
|
|---|
| 341 | SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
|
|---|
| 342 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 343 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 344 | polygon,
|
|---|
| 345 | newpolygon);
|
|---|
| 346 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 347 | // also slightly perturbed
|
|---|
| 348 | const double amplitude = 0.05;
|
|---|
| 349 | perturbPolygon(polygon, amplitude);
|
|---|
| 350 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 351 | }
|
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 | // test with three points, full rotation
|
|---|
| 355 | {
|
|---|
| 356 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 357 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 358 | polygon +=
|
|---|
| 359 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 360 | RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI),
|
|---|
| 361 | RotationAxis.rotateVector(Vector(-0.5, -sqrt(3)*0.5,0.), 47.6/180*M_PI);
|
|---|
| 362 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 363 | SPD.get<3>();
|
|---|
| 364 | SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
|
|---|
| 365 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 366 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 367 | polygon,
|
|---|
| 368 | newpolygon);
|
|---|
| 369 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 370 | // also slightly perturbed
|
|---|
| 371 | const double amplitude = 0.05;
|
|---|
| 372 | perturbPolygon(polygon, amplitude);
|
|---|
| 373 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 | /** UnitTest for matchSphericalPointDistributions() with four points
|
|---|
| 378 | */
|
|---|
| 379 | void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_4()
|
|---|
| 380 | {
|
|---|
| 381 | SphericalPointDistribution SPD(1.);
|
|---|
| 382 |
|
|---|
| 383 | // test with one point, matching trivially
|
|---|
| 384 | {
|
|---|
| 385 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 386 | polygon += Vector(1.,0.,0.);
|
|---|
| 387 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 388 | SPD.get<4>();
|
|---|
| 389 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 390 | expected.pop_front(); // remove first point
|
|---|
| 391 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 392 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 393 | polygon,
|
|---|
| 394 | newpolygon);
|
|---|
| 395 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 | // test with one point, just a flip of axis
|
|---|
| 399 | {
|
|---|
| 400 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 401 | polygon += Vector(0.,1.,0.);
|
|---|
| 402 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 403 | SPD.get<4>();
|
|---|
| 404 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 405 | expected.pop_front(); // remove first point
|
|---|
| 406 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 407 | iter != expected.end(); ++iter) {
|
|---|
| 408 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 409 | (*iter)[0] *= -1.;
|
|---|
| 410 | }
|
|---|
| 411 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 412 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 413 | polygon,
|
|---|
| 414 | newpolygon);
|
|---|
| 415 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | // test with two points, matching trivially
|
|---|
| 419 | {
|
|---|
| 420 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 421 | polygon += Vector(1.,0.,0.), Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.);
|
|---|
| 422 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 423 | SPD.get<4>();
|
|---|
| 424 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 425 | expected.pop_front(); // remove first point
|
|---|
| 426 | expected.pop_front(); // remove second point
|
|---|
| 427 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 428 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 429 | polygon,
|
|---|
| 430 | newpolygon);
|
|---|
| 431 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 432 | // also slightly perturbed
|
|---|
| 433 | const double amplitude = 0.05;
|
|---|
| 434 | perturbPolygon(polygon, amplitude);
|
|---|
| 435 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | // test with two points, matching trivially, also with slightly perturbed
|
|---|
| 439 | {
|
|---|
| 440 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 441 | polygon += Vector(1.,0.,0.), Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.);
|
|---|
| 442 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 443 | SPD.get<4>();
|
|---|
| 444 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 445 | expected.pop_front(); // remove first point
|
|---|
| 446 | expected.pop_front(); // remove second point
|
|---|
| 447 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 448 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 449 | polygon,
|
|---|
| 450 | newpolygon);
|
|---|
| 451 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 452 | // also slightly perturbed
|
|---|
| 453 | const double amplitude = 0.05;
|
|---|
| 454 | perturbPolygon(polygon, amplitude);
|
|---|
| 455 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | // test with two points, full rotation
|
|---|
| 459 | {
|
|---|
| 460 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 461 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 462 | polygon +=
|
|---|
| 463 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 464 | RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI);
|
|---|
| 465 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 466 | SPD.get<4>();
|
|---|
| 467 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 468 | expected.pop_front(); // remove first point
|
|---|
| 469 | expected.pop_front(); // remove second point
|
|---|
| 470 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 471 | iter != expected.end(); ++iter)
|
|---|
| 472 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 473 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 474 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 475 | polygon,
|
|---|
| 476 | newpolygon);
|
|---|
| 477 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 478 | // also slightly perturbed
|
|---|
| 479 | const double amplitude = 0.05;
|
|---|
| 480 | perturbPolygon(polygon, amplitude);
|
|---|
| 481 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | // test with three points, matching trivially
|
|---|
| 485 | {
|
|---|
| 486 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 487 | polygon +=
|
|---|
| 488 | Vector(1.,0.,0.),
|
|---|
| 489 | Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.),
|
|---|
| 490 | Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3));
|
|---|
| 491 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 492 | SPD.get<4>();
|
|---|
| 493 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 494 | expected.pop_front(); // remove first point
|
|---|
| 495 | expected.pop_front(); // remove second point
|
|---|
| 496 | expected.pop_front(); // remove third point
|
|---|
| 497 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 498 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 499 | polygon,
|
|---|
| 500 | newpolygon);
|
|---|
| 501 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 502 | // also slightly perturbed
|
|---|
| 503 | const double amplitude = 0.05;
|
|---|
| 504 | perturbPolygon(polygon, amplitude);
|
|---|
| 505 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | // test with three points, full rotation
|
|---|
| 509 | {
|
|---|
| 510 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 511 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 512 | polygon +=
|
|---|
| 513 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 514 | RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI),
|
|---|
| 515 | RotationAxis.rotateVector(Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 47.6/180*M_PI);
|
|---|
| 516 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 517 | SPD.get<4>();
|
|---|
| 518 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 519 | expected.pop_front(); // remove first point
|
|---|
| 520 | expected.pop_front(); // remove second point
|
|---|
| 521 | expected.pop_front(); // remove third point
|
|---|
| 522 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 523 | iter != expected.end(); ++iter)
|
|---|
| 524 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 525 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 526 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 527 | polygon,
|
|---|
| 528 | newpolygon);
|
|---|
| 529 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 530 | // also slightly perturbed
|
|---|
| 531 | const double amplitude = 0.05;
|
|---|
| 532 | perturbPolygon(polygon, amplitude);
|
|---|
| 533 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 534 | }
|
|---|
| 535 | }
|
|---|
| 536 |
|
|---|
| 537 | /** UnitTest for matchSphericalPointDistributions() with five points
|
|---|
| 538 | */
|
|---|
| 539 | void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_5()
|
|---|
| 540 | {
|
|---|
| 541 | SphericalPointDistribution SPD(1.);
|
|---|
| 542 |
|
|---|
| 543 | // test with one point, matching trivially
|
|---|
| 544 | {
|
|---|
| 545 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 546 | polygon += Vector(1.,0.,0.);
|
|---|
| 547 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 548 | SPD.get<5>();
|
|---|
| 549 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 550 | expected.pop_front(); // remove first point
|
|---|
| 551 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 552 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 553 | polygon,
|
|---|
| 554 | newpolygon);
|
|---|
| 555 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | // test with one point, just a flip of axis
|
|---|
| 559 | {
|
|---|
| 560 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 561 | polygon += Vector(0.,1.,0.);
|
|---|
| 562 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 563 | SPD.get<5>();
|
|---|
| 564 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 565 | expected.pop_front(); // remove first point
|
|---|
| 566 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 567 | iter != expected.end(); ++iter) {
|
|---|
| 568 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 569 | (*iter)[0] *= -1.;
|
|---|
| 570 | }
|
|---|
| 571 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 572 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 573 | polygon,
|
|---|
| 574 | newpolygon);
|
|---|
| 575 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| 578 | // test with two points, matching trivially
|
|---|
| 579 | {
|
|---|
| 580 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 581 | polygon += Vector(1.,0.,0.), Vector(-1.,0.,0.);
|
|---|
| 582 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 583 | SPD.get<5>();
|
|---|
| 584 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 585 | expected.pop_front(); // remove first point
|
|---|
| 586 | expected.pop_front(); // remove second point
|
|---|
| 587 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 588 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 589 | polygon,
|
|---|
| 590 | newpolygon);
|
|---|
| 591 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 592 | // also slightly perturbed
|
|---|
| 593 | const double amplitude = 0.05;
|
|---|
| 594 | perturbPolygon(polygon, amplitude);
|
|---|
| 595 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | // test with two points, full rotation
|
|---|
| 599 | {
|
|---|
| 600 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 601 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 602 | polygon +=
|
|---|
| 603 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180.*M_PI),
|
|---|
| 604 | RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180.*M_PI);
|
|---|
| 605 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 606 | SPD.get<5>();
|
|---|
| 607 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 608 | expected.pop_front(); // remove first point
|
|---|
| 609 | expected.pop_front(); // remove second point
|
|---|
| 610 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 611 | iter != expected.end(); ++iter)
|
|---|
| 612 | *iter = RotationAxis.rotateVector(*iter, 47.6/180.*M_PI);
|
|---|
| 613 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 614 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 615 | polygon,
|
|---|
| 616 | newpolygon);
|
|---|
| 617 | // the three remaining points sit on a plane that may be rotated arbitrarily
|
|---|
| 618 | // so we cannot simply check for equality between expected and remaining
|
|---|
| 619 | // hence, we just check that they are orthogonal to the first two points
|
|---|
| 620 | CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() );
|
|---|
| 621 | for (SphericalPointDistribution::Polygon_t::const_iterator fixiter = polygon.begin();
|
|---|
| 622 | fixiter != polygon.end(); ++fixiter) {
|
|---|
| 623 | for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin();
|
|---|
| 624 | iter != remaining.end(); ++iter) {
|
|---|
| 625 | CPPUNIT_ASSERT( (*fixiter).IsNormalTo(*iter) );
|
|---|
| 626 | }
|
|---|
| 627 | }
|
|---|
| 628 | }
|
|---|
| 629 |
|
|---|
| 630 | // test with three points, matching trivially
|
|---|
| 631 | {
|
|---|
| 632 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 633 | polygon +=
|
|---|
| 634 | Vector(1.,0.,0.),
|
|---|
| 635 | Vector(-1., 0.0, 0.0),
|
|---|
| 636 | Vector(0.0, 1., 0.0);
|
|---|
| 637 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 638 | SPD.get<5>();
|
|---|
| 639 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 640 | expected.pop_front(); // remove first point
|
|---|
| 641 | expected.pop_front(); // remove second point
|
|---|
| 642 | expected.pop_front(); // remove third point
|
|---|
| 643 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 644 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 645 | polygon,
|
|---|
| 646 | newpolygon);
|
|---|
| 647 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 648 | // also slightly perturbed
|
|---|
| 649 | const double amplitude = 0.05;
|
|---|
| 650 | perturbPolygon(polygon, amplitude);
|
|---|
| 651 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 | // test with three points, full rotation
|
|---|
| 655 | {
|
|---|
| 656 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 657 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 658 | polygon +=
|
|---|
| 659 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 660 | RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI),
|
|---|
| 661 | RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI);
|
|---|
| 662 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 663 | SPD.get<5>();
|
|---|
| 664 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 665 | expected.pop_front(); // remove first point
|
|---|
| 666 | expected.pop_front(); // remove second point
|
|---|
| 667 | expected.pop_front(); // remove third point
|
|---|
| 668 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 669 | iter != expected.end(); ++iter)
|
|---|
| 670 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 671 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 672 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 673 | polygon,
|
|---|
| 674 | newpolygon);
|
|---|
| 675 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 676 | // also slightly perturbed
|
|---|
| 677 | const double amplitude = 0.05;
|
|---|
| 678 | perturbPolygon(polygon, amplitude);
|
|---|
| 679 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 680 | }
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| 683 | /** UnitTest for matchSphericalPointDistributions() with six points
|
|---|
| 684 | */
|
|---|
| 685 | void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_6()
|
|---|
| 686 | {
|
|---|
| 687 | SphericalPointDistribution SPD(1.);
|
|---|
| 688 |
|
|---|
| 689 | // test with one point, matching trivially
|
|---|
| 690 | {
|
|---|
| 691 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 692 | polygon += Vector(1.,0.,0.);
|
|---|
| 693 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 694 | SPD.get<6>();
|
|---|
| 695 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 696 | expected.pop_front(); // remove first point
|
|---|
| 697 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 698 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 699 | polygon,
|
|---|
| 700 | newpolygon);
|
|---|
| 701 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 702 | }
|
|---|
| 703 |
|
|---|
| 704 | // test with one point, just a flip of axis
|
|---|
| 705 | {
|
|---|
| 706 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 707 | polygon += Vector(0.,1.,0.);
|
|---|
| 708 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 709 | SPD.get<6>();
|
|---|
| 710 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 711 | expected.pop_front(); // remove first point
|
|---|
| 712 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 713 | iter != expected.end(); ++iter) {
|
|---|
| 714 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 715 | (*iter)[0] *= -1.;
|
|---|
| 716 | }
|
|---|
| 717 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 718 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 719 | polygon,
|
|---|
| 720 | newpolygon);
|
|---|
| 721 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 722 | }
|
|---|
| 723 |
|
|---|
| 724 | // test with two points, matching trivially
|
|---|
| 725 | {
|
|---|
| 726 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 727 | polygon += Vector(1.,0.,0.), Vector(-1.,0.,0.);
|
|---|
| 728 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 729 | SPD.get<6>();
|
|---|
| 730 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 731 | expected.pop_front(); // remove first point
|
|---|
| 732 | expected.pop_front(); // remove second spoint
|
|---|
| 733 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 734 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 735 | polygon,
|
|---|
| 736 | newpolygon);
|
|---|
| 737 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 738 | // also slightly perturbed
|
|---|
| 739 | const double amplitude = 0.05;
|
|---|
| 740 | perturbPolygon(polygon, amplitude);
|
|---|
| 741 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 742 | }
|
|---|
| 743 |
|
|---|
| 744 | // test with two points, full rotation
|
|---|
| 745 | {
|
|---|
| 746 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 747 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 748 | polygon +=
|
|---|
| 749 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 750 | RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
|
|---|
| 751 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 752 | SPD.get<6>();
|
|---|
| 753 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 754 | expected.pop_front(); // remove first point
|
|---|
| 755 | expected.pop_front(); // remove second spoint
|
|---|
| 756 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 757 | iter != expected.end(); ++iter)
|
|---|
| 758 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 759 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 760 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 761 | polygon,
|
|---|
| 762 | newpolygon);
|
|---|
| 763 | // the four remaining points sit on a plane that may have been rotated arbitrarily
|
|---|
| 764 | // so we cannot simply check for equality between expected and remaining
|
|---|
| 765 | // hence, we just check that they are orthogonal to the first two points
|
|---|
| 766 | CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() );
|
|---|
| 767 | for (SphericalPointDistribution::Polygon_t::const_iterator fixiter = polygon.begin();
|
|---|
| 768 | fixiter != polygon.end(); ++fixiter) {
|
|---|
| 769 | for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin();
|
|---|
| 770 | iter != remaining.end(); ++iter) {
|
|---|
| 771 | CPPUNIT_ASSERT( (*fixiter).IsNormalTo(*iter) );
|
|---|
| 772 | }
|
|---|
| 773 | }
|
|---|
| 774 | }
|
|---|
| 775 |
|
|---|
| 776 | // test with three points, matching trivially
|
|---|
| 777 | {
|
|---|
| 778 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 779 | polygon +=
|
|---|
| 780 | Vector(1.,0.,0.),
|
|---|
| 781 | Vector(-1., 0.0, 0.0),
|
|---|
| 782 | Vector(0.0, 1., 0.0);
|
|---|
| 783 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 784 | SPD.get<6>();
|
|---|
| 785 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 786 | expected.pop_front(); // remove first point
|
|---|
| 787 | expected.pop_front(); // remove second point
|
|---|
| 788 | expected.pop_front(); // remove third point
|
|---|
| 789 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 790 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 791 | polygon,
|
|---|
| 792 | newpolygon);
|
|---|
| 793 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 794 | // also slightly perturbed
|
|---|
| 795 | const double amplitude = 0.05;
|
|---|
| 796 | perturbPolygon(polygon, amplitude);
|
|---|
| 797 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 798 | }
|
|---|
| 799 |
|
|---|
| 800 | // test with three points, full rotation
|
|---|
| 801 | {
|
|---|
| 802 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 803 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 804 | polygon +=
|
|---|
| 805 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 806 | RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI),
|
|---|
| 807 | RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI);
|
|---|
| 808 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 809 | SPD.get<6>();
|
|---|
| 810 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 811 | expected.pop_front(); // remove first point
|
|---|
| 812 | expected.pop_front(); // remove second point
|
|---|
| 813 | expected.pop_front(); // remove third point
|
|---|
| 814 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 815 | iter != expected.end(); ++iter)
|
|---|
| 816 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 817 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 818 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 819 | polygon,
|
|---|
| 820 | newpolygon);
|
|---|
| 821 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 822 | // also slightly perturbed
|
|---|
| 823 | const double amplitude = 0.05;
|
|---|
| 824 | perturbPolygon(polygon, amplitude);
|
|---|
| 825 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 826 | }
|
|---|
| 827 | }
|
|---|
| 828 |
|
|---|
| 829 | /** UnitTest for matchSphericalPointDistributions() with seven points
|
|---|
| 830 | */
|
|---|
| 831 | void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_7()
|
|---|
| 832 | {
|
|---|
| 833 | SphericalPointDistribution SPD(1.);
|
|---|
| 834 |
|
|---|
| 835 | // test with one point, matching trivially
|
|---|
| 836 | {
|
|---|
| 837 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 838 | polygon += Vector(1.,0.,0.);
|
|---|
| 839 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 840 | SPD.get<7>();
|
|---|
| 841 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 842 | expected.pop_front(); // remove first point
|
|---|
| 843 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 844 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 845 | polygon,
|
|---|
| 846 | newpolygon);
|
|---|
| 847 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 848 | }
|
|---|
| 849 |
|
|---|
| 850 | // test with one point, just a flip of axis
|
|---|
| 851 | {
|
|---|
| 852 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 853 | polygon += Vector(0.,1.,0.);
|
|---|
| 854 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 855 | SPD.get<7>();
|
|---|
| 856 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 857 | expected.pop_front(); // remove first point
|
|---|
| 858 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 859 | iter != expected.end(); ++iter) {
|
|---|
| 860 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 861 | (*iter)[0] *= -1.;
|
|---|
| 862 | }
|
|---|
| 863 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 864 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 865 | polygon,
|
|---|
| 866 | newpolygon);
|
|---|
| 867 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 868 | }
|
|---|
| 869 |
|
|---|
| 870 | // test with two points, matching trivially
|
|---|
| 871 | {
|
|---|
| 872 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 873 | polygon += Vector(1.,0.,0.), Vector(-1.,0.,0.);
|
|---|
| 874 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 875 | SPD.get<7>();
|
|---|
| 876 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 877 | expected.pop_front(); // remove first point
|
|---|
| 878 | expected.pop_front(); // remove second point
|
|---|
| 879 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 880 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 881 | polygon,
|
|---|
| 882 | newpolygon);
|
|---|
| 883 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 884 | // also slightly perturbed
|
|---|
| 885 | const double amplitude = 0.05;
|
|---|
| 886 | perturbPolygon(polygon, amplitude);
|
|---|
| 887 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 888 | }
|
|---|
| 889 |
|
|---|
| 890 | // test with two points, full rotation
|
|---|
| 891 | {
|
|---|
| 892 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 893 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 894 | polygon +=
|
|---|
| 895 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 896 | RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
|
|---|
| 897 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 898 | SPD.get<7>();
|
|---|
| 899 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 900 | expected.pop_front(); // remove first point
|
|---|
| 901 | expected.pop_front(); // remove second point
|
|---|
| 902 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 903 | iter != expected.end(); ++iter)
|
|---|
| 904 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 905 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 906 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 907 | polygon,
|
|---|
| 908 | newpolygon);
|
|---|
| 909 | // the five remaining points sit on a plane that may have been rotated arbitrarily
|
|---|
| 910 | // so we cannot simply check for equality between expected and remaining
|
|---|
| 911 | // hence, we just check that they are orthogonal to the first two points
|
|---|
| 912 | CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() );
|
|---|
| 913 | for (SphericalPointDistribution::Polygon_t::const_iterator fixiter = polygon.begin();
|
|---|
| 914 | fixiter != polygon.end(); ++fixiter) {
|
|---|
| 915 | for (SphericalPointDistribution::Polygon_t::const_iterator iter = remaining.begin();
|
|---|
| 916 | iter != remaining.end(); ++iter) {
|
|---|
| 917 | CPPUNIT_ASSERT( (*fixiter).IsNormalTo(*iter) );
|
|---|
| 918 | }
|
|---|
| 919 | }
|
|---|
| 920 | }
|
|---|
| 921 |
|
|---|
| 922 | // test with three points, matching trivially
|
|---|
| 923 | {
|
|---|
| 924 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 925 | polygon +=
|
|---|
| 926 | Vector(1.,0.,0.),
|
|---|
| 927 | Vector(-1., 0.0, 0.0),
|
|---|
| 928 | Vector(0.0, 1., 0.0);
|
|---|
| 929 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 930 | SPD.get<7>();
|
|---|
| 931 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 932 | expected.pop_front(); // remove first point
|
|---|
| 933 | expected.pop_front(); // remove second point
|
|---|
| 934 | expected.pop_front(); // remove third point
|
|---|
| 935 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 936 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 937 | polygon,
|
|---|
| 938 | newpolygon);
|
|---|
| 939 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 940 | // also slightly perturbed
|
|---|
| 941 | const double amplitude = 0.05;
|
|---|
| 942 | perturbPolygon(polygon, amplitude);
|
|---|
| 943 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 944 | }
|
|---|
| 945 |
|
|---|
| 946 | // test with three points, full rotation
|
|---|
| 947 | {
|
|---|
| 948 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 949 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 950 | polygon +=
|
|---|
| 951 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 952 | RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI),
|
|---|
| 953 | RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI);
|
|---|
| 954 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 955 | SPD.get<7>();
|
|---|
| 956 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 957 | expected.pop_front(); // remove first point
|
|---|
| 958 | expected.pop_front(); // remove second point
|
|---|
| 959 | expected.pop_front(); // remove third point
|
|---|
| 960 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 961 | iter != expected.end(); ++iter)
|
|---|
| 962 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 963 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 964 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 965 | polygon,
|
|---|
| 966 | newpolygon);
|
|---|
| 967 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 968 | // also slightly perturbed
|
|---|
| 969 | const double amplitude = 0.05;
|
|---|
| 970 | perturbPolygon(polygon, amplitude);
|
|---|
| 971 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 972 | }
|
|---|
| 973 | }
|
|---|
| 974 |
|
|---|
| 975 | /** UnitTest for matchSphericalPointDistributions() with eight points
|
|---|
| 976 | */
|
|---|
| 977 | void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_8()
|
|---|
| 978 | {
|
|---|
| 979 | SphericalPointDistribution SPD(1.);
|
|---|
| 980 |
|
|---|
| 981 | // test with one point, matching trivially
|
|---|
| 982 | {
|
|---|
| 983 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 984 | polygon += Vector(1.,0.,0.);
|
|---|
| 985 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 986 | SPD.get<8>();
|
|---|
| 987 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 988 | expected.pop_front(); // remove first point
|
|---|
| 989 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 990 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 991 | polygon,
|
|---|
| 992 | newpolygon);
|
|---|
| 993 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 994 | }
|
|---|
| 995 |
|
|---|
| 996 | // test with one point, just a flip of axis
|
|---|
| 997 | {
|
|---|
| 998 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 999 | polygon += Vector(0.,1.,0.);
|
|---|
| 1000 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 1001 | SPD.get<8>();
|
|---|
| 1002 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 1003 | expected.pop_front(); // remove first point
|
|---|
| 1004 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1005 | iter != expected.end(); ++iter) {
|
|---|
| 1006 | std::swap((*iter)[0], (*iter)[1]);
|
|---|
| 1007 | (*iter)[0] *= -1.;
|
|---|
| 1008 | }
|
|---|
| 1009 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1010 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 1011 | polygon,
|
|---|
| 1012 | newpolygon);
|
|---|
| 1013 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1014 | }
|
|---|
| 1015 |
|
|---|
| 1016 | // test with two points, matching trivially
|
|---|
| 1017 | {
|
|---|
| 1018 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 1019 | polygon += Vector(1.,0.,0.), Vector(-1.,0.,0.);
|
|---|
| 1020 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 1021 | SPD.get<8>();
|
|---|
| 1022 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 1023 | expected.pop_front(); // remove first point
|
|---|
| 1024 | expected.pop_front(); // remove second point
|
|---|
| 1025 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1026 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 1027 | polygon,
|
|---|
| 1028 | newpolygon);
|
|---|
| 1029 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1030 | // also slightly perturbed
|
|---|
| 1031 | const double amplitude = 0.05;
|
|---|
| 1032 | perturbPolygon(polygon, amplitude);
|
|---|
| 1033 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1034 | }
|
|---|
| 1035 |
|
|---|
| 1036 | // test with two points, full rotation
|
|---|
| 1037 | {
|
|---|
| 1038 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 1039 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 1040 | polygon +=
|
|---|
| 1041 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 1042 | RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
|
|---|
| 1043 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 1044 | SPD.get<8>();
|
|---|
| 1045 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 1046 | expected.pop_front(); // remove first point
|
|---|
| 1047 | expected.pop_front(); // remove second point
|
|---|
| 1048 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1049 | iter != expected.end(); ++iter)
|
|---|
| 1050 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 1051 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1052 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 1053 | polygon,
|
|---|
| 1054 | newpolygon);
|
|---|
| 1055 | // the six remaining points sit on two planes that may have been rotated arbitrarily
|
|---|
| 1056 | // so we cannot simply check for equality between expected and remaining
|
|---|
| 1057 | // hence, we just check that they are orthogonal to the first two points
|
|---|
| 1058 | CPPUNIT_ASSERT_EQUAL( expected.size(), remaining.size() );
|
|---|
| 1059 | for (SphericalPointDistribution::Polygon_t::const_iterator fixiter = polygon.begin();
|
|---|
| 1060 | fixiter != polygon.end(); ++fixiter) {
|
|---|
| 1061 | SphericalPointDistribution::Polygon_t::const_iterator expectiter = expected.begin();
|
|---|
| 1062 | SphericalPointDistribution::Polygon_t::const_iterator remainiter = remaining.begin();
|
|---|
| 1063 | for (;remainiter != remaining.end(); ++expectiter, ++remainiter) {
|
|---|
| 1064 | // check that points in expected/remaining have same angle to the given ones
|
|---|
| 1065 | // CPPUNIT_ASSERT_EQUAL( (*expectiter).Angle(*fixiter), (*remainiter).Angle(*fixiter) );
|
|---|
| 1066 | CPPUNIT_ASSERT( fabs( (*expectiter).Angle(*fixiter) - (*remainiter).Angle(*fixiter) )
|
|---|
| 1067 | < std::numeric_limits<double>::epsilon()*1e4 );
|
|---|
| 1068 | }
|
|---|
| 1069 | }
|
|---|
| 1070 | }
|
|---|
| 1071 |
|
|---|
| 1072 | // test with three points, matching trivially
|
|---|
| 1073 | {
|
|---|
| 1074 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 1075 | polygon +=
|
|---|
| 1076 | Vector(1.,0.,0.),
|
|---|
| 1077 | Vector(-1., 0.0, 0.0),
|
|---|
| 1078 | Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0);
|
|---|
| 1079 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 1080 | SPD.get<8>();
|
|---|
| 1081 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 1082 | expected.pop_front(); // remove first point
|
|---|
| 1083 | expected.pop_front(); // remove second point
|
|---|
| 1084 | expected.pop_front(); // remove third point
|
|---|
| 1085 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1086 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 1087 | polygon,
|
|---|
| 1088 | newpolygon);
|
|---|
| 1089 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1090 | // also slightly perturbed
|
|---|
| 1091 | const double amplitude = 0.05;
|
|---|
| 1092 | perturbPolygon(polygon, amplitude);
|
|---|
| 1093 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1094 | }
|
|---|
| 1095 |
|
|---|
| 1096 | // test with three points, full rotation
|
|---|
| 1097 | {
|
|---|
| 1098 | Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248));
|
|---|
| 1099 | SphericalPointDistribution::Polygon_t polygon;
|
|---|
| 1100 | polygon +=
|
|---|
| 1101 | RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI),
|
|---|
| 1102 | RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI),
|
|---|
| 1103 | RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 47.6/180*M_PI);
|
|---|
| 1104 | SphericalPointDistribution::Polygon_t newpolygon =
|
|---|
| 1105 | SPD.get<8>();
|
|---|
| 1106 | SphericalPointDistribution::Polygon_t expected = newpolygon;
|
|---|
| 1107 | expected.pop_front(); // remove first point
|
|---|
| 1108 | expected.pop_front(); // remove second point
|
|---|
| 1109 | expected.pop_front(); // remove third point
|
|---|
| 1110 | for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
|
|---|
| 1111 | iter != expected.end(); ++iter)
|
|---|
| 1112 | *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
|
|---|
| 1113 | SphericalPointDistribution::Polygon_t remaining =
|
|---|
| 1114 | SphericalPointDistribution::matchSphericalPointDistributions(
|
|---|
| 1115 | polygon,
|
|---|
| 1116 | newpolygon);
|
|---|
| 1117 | CPPUNIT_ASSERT_EQUAL( expected, remaining );
|
|---|
| 1118 | // also slightly perturbed
|
|---|
| 1119 | const double amplitude = 0.05;
|
|---|
| 1120 | perturbPolygon(polygon, amplitude);
|
|---|
| 1121 | CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
|
|---|
| 1122 | }
|
|---|
| 1123 | }
|
|---|