Index: src/Fragmentation/Exporters/SphericalPointDistribution.cpp
===================================================================
--- src/Fragmentation/Exporters/SphericalPointDistribution.cpp	(revision f54930fdd572cf1e5e916da920bdad10f75cd695)
+++ src/Fragmentation/Exporters/SphericalPointDistribution.cpp	(revision 0241c59e7f10c73f87336715af0aadac2b2d4db1)
@@ -38,13 +38,8 @@
 
 #include "CodePatterns/Assert.hpp"
-#include "CodePatterns/IteratorAdaptors.hpp"
-#include "CodePatterns/toString.hpp"
+#include "CodePatterns/Log.hpp"
 
 #include <algorithm>
-#include <cmath>
-#include <limits>
-#include <list>
 #include <vector>
-#include <map>
 
 #include "LinearAlgebra/Line.hpp"
@@ -52,271 +47,55 @@
 #include "LinearAlgebra/Vector.hpp"
 
-typedef std::list<unsigned int> IndexList_t;
-typedef std::vector<unsigned int> IndexArray_t;
-typedef std::vector<Vector> VectorArray_t;
-typedef std::vector<double> DistanceArray_t;
-
-DistanceArray_t calculatePairwiseDistances(
-    const std::vector<Vector> &_points,
-    const IndexList_t &_indices
-    )
+void SphericalPointDistribution::initSelf(const int _NumberOfPoints)
 {
-  DistanceArray_t result;
-  for (IndexList_t::const_iterator firstiter = _indices.begin();
-      firstiter != _indices.end(); ++firstiter) {
-    for (IndexList_t::const_iterator seconditer = firstiter;
-        seconditer != _indices.end(); ++seconditer) {
-      if (firstiter == seconditer)
-        continue;
-      const double distance = (_points[*firstiter] - _points[*seconditer]).NormSquared();
-      result.push_back(distance);
-    }
+  switch (_NumberOfPoints)
+  {
+    case 0:
+      points = get<0>();
+      break;
+    case 1:
+      points = get<1>();
+      break;
+    case 2:
+      points = get<2>();
+      break;
+    case 3:
+      points = get<3>();
+      break;
+    case 4:
+      points = get<4>();
+      break;
+    case 5:
+      points = get<5>();
+      break;
+    case 6:
+      points = get<6>();
+      break;
+    case 7:
+      points = get<7>();
+      break;
+    case 8:
+      points = get<8>();
+      break;
+    case 9:
+      points = get<9>();
+      break;
+    case 10:
+      points = get<10>();
+      break;
+    case 11:
+      points = get<11>();
+      break;
+    case 12:
+      points = get<12>();
+      break;
+    case 14:
+      points = get<14>();
+      break;
+    default:
+      ASSERT(0, "SphericalPointDistribution::initSelf() - cannot deal with the case "
+          +toString(_NumberOfPoints)+".");
   }
-  return result;
+  LOG(3, "DEBUG: Ideal polygon is " << points);
 }
 
-// class generator: taken from www.cplusplus.com example std::generate
-struct c_unique {
-  int current;
-  c_unique() {current=0;}
-  int operator()() {return ++current;}
-} UniqueNumber;
-
-/** Returns squared L2 error of the given \a _Matching.
- *
- * We compare the pair-wise distances of each associated matching
- * and check whether these distances each match between \a _old and
- * \a _new.
- *
- * \param _old first set of points (fewer or equal to \a _new)
- * \param _new second set of points
- * \param _Matching matching between the two sets
- * \return pair with L1 and squared L2 error
- */
-std::pair<double, double> calculateErrorOfMatching(
-    const std::vector<Vector> &_old,
-    const std::vector<Vector> &_new,
-    const IndexList_t &_Matching)
-{
-  std::pair<double, double> errors( std::make_pair( 0., 0. ) );
-
-  if (_Matching.size() > 1) {
-    // convert matching into two vectors to calculate distance among another
-
-    // calculate all pair-wise distances
-    IndexList_t keys(_Matching.size());
-    std::generate (keys.begin(), keys.end(), UniqueNumber);
-    const DistanceArray_t firstdistances = calculatePairwiseDistances(_old, keys);
-    const DistanceArray_t seconddistances = calculatePairwiseDistances(_new, _Matching);
-
-    ASSERT( firstdistances.size() == seconddistances.size(),
-        "calculateL2ErrorOfMatching() - mismatch in pair-wise distance array sizes.");
-    DistanceArray_t::const_iterator firstiter = firstdistances.begin();
-    DistanceArray_t::const_iterator seconditer = seconddistances.begin();
-    for (;(firstiter != firstdistances.end()) && (seconditer != seconddistances.end());
-        ++firstiter, ++seconditer) {
-      const double gap = *firstiter - *seconditer;
-      // L1 error
-      if (errors.first < gap)
-        errors.first = gap;
-      // L2 error
-      errors.second += gap*gap;
-    }
-  }
-
-  return errors;
-}
-
-SphericalPointDistribution::Polygon_t removeMatchingPoints(
-    const SphericalPointDistribution::Polygon_t &_points,
-    const IndexList_t &_matchingindices
-    )
-{
-  SphericalPointDistribution::Polygon_t remainingpoints;
-  IndexArray_t indices(_matchingindices.begin(), _matchingindices.end());
-  std::sort(indices.begin(), indices.end());
-  IndexArray_t::const_iterator valueiter = indices.begin();
-  SphericalPointDistribution::Polygon_t::const_iterator pointiter =
-      _points.begin();
-  for (unsigned int i=0; i< _points.size(); ++i, ++pointiter) {
-    // skip all those in values
-    if (*valueiter == i)
-      ++valueiter;
-    else
-      remainingpoints.push_back(*pointiter);
-  }
-
-  return remainingpoints;
-}
-
-/** Rotates a given polygon around x, y, and z axis by the given angles.
- *
- * Essentially, we concentrate on the three points of the polygon to rotate
- * to the correct position. First, we rotate its center via \a angles,
- * then we rotate the "triangle" around itself/\a _RotationAxis by
- * \a _RotationAngle.
- *
- * \param _polygon polygon whose points to rotate
- * \param _angles vector with rotation angles for x,y,z axis
- * \param _RotationAxis
- * \param _RotationAngle
- */
-SphericalPointDistribution::Polygon_t rotatePolygon(
-    const SphericalPointDistribution::Polygon_t &_polygon,
-    const std::vector<double> &_angles,
-    const Line &_RotationAxis,
-    const double _RotationAngle)
-{
-  SphericalPointDistribution::Polygon_t rotated_polygon = _polygon;
-  RealSpaceMatrix rotation;
-  ASSERT( _angles.size() == 3,
-      "rotatePolygon() - not exactly "+toString(3)+" angles given.");
-  rotation.setRotation(_angles[0] * M_PI/180., _angles[1] * M_PI/180., _angles[2] * M_PI/180.);
-
-  // apply rotation angles
-  for (SphericalPointDistribution::Polygon_t::iterator iter = rotated_polygon.begin();
-      iter != rotated_polygon.end(); ++iter) {
-    *iter = rotation * (*iter);
-    _RotationAxis.rotateVector(*iter, _RotationAngle);
-  }
-
-  return rotated_polygon;
-}
-
-struct MatchingControlStructure {
-  bool foundflag;
-  double bestL2;
-  IndexList_t bestmatching;
-  VectorArray_t oldpoints;
-  VectorArray_t newpoints;
-};
-
-/** Recursive function to go through all possible matchings.
- *
- * \param _MCS structure holding global information to the recursion
- * \param _matching current matching being build up
- * \param _indices contains still available indices
- * \param _matchingsize
- */
-void recurseMatchings(
-    MatchingControlStructure &_MCS,
-    IndexList_t &_matching,
-    IndexList_t _indices,
-    unsigned int _matchingsize)
-{
-  //!> threshold for L1 error below which matching is immediately acceptable
-  const double L1THRESHOLD = 1e-2;
-  if (!_MCS.foundflag) {
-    if (_matching.size() < _matchingsize) {
-      // go through all indices
-      for (IndexList_t::iterator iter = _indices.begin();
-          iter != _indices.end();) {
-        // add index to matching
-        _matching.push_back(*iter);
-        // remove index but keep iterator to position (is the next to erase element)
-        IndexList_t::iterator backupiter = _indices.erase(iter);
-        // recurse with decreased _matchingsize
-        recurseMatchings(_MCS, _matching, _indices, _matchingsize-1);
-        // re-add chosen index and reset index to new position
-        _indices.insert(backupiter, _matching.back());
-        iter = backupiter;
-        // remove index from _matching to make space for the next one
-        _matching.pop_back();
-      }
-      // gone through all indices then exit recursion
-      _MCS.foundflag = true;
-    } else {
-      // calculate errors
-      std::pair<double, double> errors = calculateErrorOfMatching(
-          _MCS.oldpoints, _MCS.newpoints, _matching);
-      if (errors.first < L1THRESHOLD) {
-        _MCS.bestmatching = _matching;
-        _MCS.foundflag = true;
-      }
-      if (_MCS.bestL2 > errors.second) {
-        _MCS.bestmatching = _matching;
-        _MCS.bestL2 = errors.second;
-      }
-    }
-  }
-}
-
-SphericalPointDistribution::Polygon_t
-SphericalPointDistribution::matchSphericalPointDistributions(
-    const SphericalPointDistribution::Polygon_t &_polygon,
-    const SphericalPointDistribution::Polygon_t &_newpolygon
-    )
-{
-  SphericalPointDistribution::Polygon_t remainingpoints;
-  VectorArray_t remainingold(_polygon.begin(), _polygon.end());
-  VectorArray_t remainingnew(_newpolygon.begin(), _newpolygon.end());
-
-  if (_polygon.size() > 0) {
-    MatchingControlStructure MCS;
-    MCS.foundflag = false;
-    MCS.bestL2 = std::numeric_limits<double>::max();
-    MCS.oldpoints.insert(MCS.oldpoints.begin(), _polygon.begin(),_polygon.end() );
-    MCS.newpoints.insert(MCS.newpoints.begin(), _newpolygon.begin(),_newpolygon.end() );
-
-    // search for bestmatching combinatorially
-    {
-      // translate polygon into vector to enable index addressing
-      IndexList_t indices(_newpolygon.size());
-      std::generate(indices.begin(), indices.end(), UniqueNumber);
-      IndexList_t matching;
-
-      // walk through all matchings
-      const unsigned int matchingsize = _polygon.size();
-      ASSERT( matchingsize <= indices.size(),
-          "SphericalPointDistribution::matchSphericalPointDistributions() - not enough new points to choose for matching to old ones.");
-      recurseMatchings(MCS, matching, indices, matchingsize);
-    }
-
-    // determine rotation angles to align the two point distributions with
-    // respect to bestmatching
-    std::vector<double> angles(3);
-    Vector newCenter;
-    {
-      // calculate center of triangle/line/point consisting of first points of matching
-      Vector oldCenter;
-      IndexList_t::const_iterator iter = MCS.bestmatching.begin();
-      unsigned int i = 0;
-      for (; (i<3) && (i<MCS.bestmatching.size()); ++i, ++iter) {
-        oldCenter += remainingold[i];
-        newCenter += remainingnew[*iter];
-      }
-      oldCenter *= 1./(double)i;
-      newCenter *= 1./(double)i;
-
-      Vector direction(0.,0.,0.);
-      for(size_t i=0;i<NDIM;++i) {
-        // create new rotation axis
-        direction[i] = 1.;
-        const Line axis (zeroVec, direction);
-        // calculate rotation angle for this axis
-        const double alpha = direction.Angle(oldCenter) - direction.Angle(newCenter);
-        // perform rotation
-        axis.rotateVector(newCenter, alpha);
-        // store angle
-        angles[i] = alpha;
-        // reset direction component for next iteration
-        direction[i] = 0.;
-      }
-    }
-    const Line RotationAxis(zeroVec, newCenter);
-    const double RotationAngle =
-        newCenter.Angle(remainingold[0])
-        - newCenter.Angle(remainingnew[*MCS.bestmatching.begin()]);
-
-    // rotate _newpolygon
-    SphericalPointDistribution::Polygon_t rotated_newpolygon =
-        rotatePolygon(_newpolygon, angles, RotationAxis, RotationAngle);
-
-    // remove all points in matching and return remaining ones
-    return removeMatchingPoints(rotated_newpolygon, MCS.bestmatching);
-  } else
-    return _newpolygon;
-}
-
-
-
Index: src/Fragmentation/Exporters/SphericalPointDistribution.hpp
===================================================================
--- src/Fragmentation/Exporters/SphericalPointDistribution.hpp	(revision f54930fdd572cf1e5e916da920bdad10f75cd695)
+++ src/Fragmentation/Exporters/SphericalPointDistribution.hpp	(revision 0241c59e7f10c73f87336715af0aadac2b2d4db1)
@@ -57,21 +57,9 @@
   }
 
-
-  /** Matches a given spherical distribution with another containing more
-   * points.
+  /** Initializes the polygon with the given \a _NumberOfPoints.
    *
-   * This is a helper to determine points where to best insert saturation
-   * hydrogens.
-   *
-   * \param _polygon current occupied positions
-   * \param _newpolygon ideal distribution to match best with current occupied
-   *        positions
-   * \return remaining vacant positions relative to \a _polygon
+   * \param _NumberOfPoints number of points
    */
-  static Polygon_t matchSphericalPointDistributions(
-      const Polygon_t &_polygon,
-      const Polygon_t &_newpolygon
-      );
-
+  void initSelf(const int _NumberOfPoints);
 
   //!> default radius of the spherical distribution
@@ -79,4 +67,6 @@
   //!> precalculated value for root of 3
   const double SQRT_3;
+  //!> points in this polygon
+  Polygon_t points;
 };
 
Index: src/Fragmentation/Exporters/unittests/Makefile.am
===================================================================
--- src/Fragmentation/Exporters/unittests/Makefile.am	(revision f54930fdd572cf1e5e916da920bdad10f75cd695)
+++ src/Fragmentation/Exporters/unittests/Makefile.am	(revision 0241c59e7f10c73f87336715af0aadac2b2d4db1)
@@ -5,18 +5,15 @@
 	../Fragmentation/Exporters/unittests/HydrogenPoolUnitTest.cpp \
 	../Fragmentation/Exporters/unittests/SaturatedFragmentUnitTest.cpp \
-	../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.cpp \
-	../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
+	../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.cpp
 
 FRAGMENTATIONEXPORTERSTESTSHEADERS = \
 	../Fragmentation/Exporters/unittests/HydrogenPoolUnitTest.hpp \
 	../Fragmentation/Exporters/unittests/SaturatedFragmentUnitTest.hpp \
-	../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.hpp \
-	../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
+	../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.hpp
 
 FRAGMENTATIONEXPORTERSTESTS = \
 	HydrogenPoolUnitTest \
 	SaturatedFragmentUnitTest \
-	SaturationDistanceMaximizerUnitTest \
-	SphericalPointDistributionUnitTest
+	SaturationDistanceMaximizerUnitTest
 
 TESTS += $(FRAGMENTATIONEXPORTERSTESTS)
@@ -48,5 +45,4 @@
 
 SaturationDistanceMaximizerUnitTest_SOURCES = \
-	../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.cpp \
 	../Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.hpp \
 	../Fragmentation/Exporters/unittests/stubs/SaturatedBondStub.cpp
@@ -55,12 +51,4 @@
 	$(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
 	${FRAGMENTATIONEXPORTERSLIBS}
-	
-SphericalPointDistributionUnitTest_SOURCES = \
-	../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp \
-	../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
-SphericalPointDistributionUnitTest_LDADD = \
-	../libMolecuilderUI.la  \
-	$(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
-	${FRAGMENTATIONEXPORTERSLIBS}
 
 
Index: src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
===================================================================
--- src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp	(revision f54930fdd572cf1e5e916da920bdad10f75cd695)
+++ 	(revision )
@@ -1,132 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2014 Frederik Heber. All rights reserved.
- * 
- *
- *   This file is part of MoleCuilder.
- *
- *    MoleCuilder is free software: you can redistribute it and/or modify
- *    it under the terms of the GNU General Public License as published by
- *    the Free Software Foundation, either version 2 of the License, or
- *    (at your option) any later version.
- *
- *    MoleCuilder is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *    GNU General Public License for more details.
- *
- *    You should have received a copy of the GNU General Public License
- *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * SphericalPointDistributionUnitTest.cpp
- *
- *  Created on: May 29, 2014
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-using namespace std;
-
-#include <cppunit/CompilerOutputter.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TestRunner.h>
-
-// include headers that implement a archive in simple text format
-#include <boost/archive/text_oarchive.hpp>
-#include <boost/archive/text_iarchive.hpp>
-
-#include "SphericalPointDistributionUnitTest.hpp"
-
-#include <boost/assign.hpp>
-
-#include "CodePatterns/Assert.hpp"
-
-#include "Fragmentation/Exporters/SphericalPointDistribution.hpp"
-
-#ifdef HAVE_TESTRUNNER
-#include "UnitTestMain.hpp"
-#endif /*HAVE_TESTRUNNER*/
-
-using namespace boost::assign;
-
-/********************************************** Test classes **************************************/
-
-// Registers the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION( SphericalPointDistributionTest );
-
-
-void SphericalPointDistributionTest::setUp()
-{
-  // failing asserts should be thrown
-  ASSERT_DO(Assert::Throw);
-}
-
-
-void SphericalPointDistributionTest::tearDown()
-{
-}
-
-/** UnitTest for matchSphericalPointDistributions() with two points
- */
-void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2()
-{
-  SphericalPointDistribution SPD(1.);
-  // test with one point, matching trivially
-  {
-    SphericalPointDistribution::Polygon_t polygon;
-    polygon += Vector(1.,0.,0.);
-    SphericalPointDistribution::Polygon_t newpolygon =
-        SPD.get<2>();
-    SphericalPointDistribution::Polygon_t expected;
-    expected += Vector(-1.,0.,0.);
-    SphericalPointDistribution::Polygon_t remaining =
-        SphericalPointDistribution::matchSphericalPointDistributions(
-            polygon,
-            newpolygon);
-    CPPUNIT_ASSERT_EQUAL( expected, remaining );
-  }
-
-  // test with one point, just a flip of axis
-  {
-    SphericalPointDistribution::Polygon_t polygon;
-    polygon += Vector(0.,1.,0.);
-    SphericalPointDistribution::Polygon_t newpolygon =
-        SPD.get<2>();
-    SphericalPointDistribution::Polygon_t expected;
-    expected += Vector(-1.,0.,0.);
-    SphericalPointDistribution::Polygon_t remaining =
-        SphericalPointDistribution::matchSphericalPointDistributions(
-            polygon,
-            newpolygon);
-    CPPUNIT_ASSERT_EQUAL( expected, remaining );
-  }
-}
-
-/** UnitTest for matchSphericalPointDistributions() with three points
- */
-void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_3()
-{
-  SphericalPointDistribution SPD(1.);
-
-  // test with one point, matching trivially
-  {
-    SphericalPointDistribution::Polygon_t polygon;
-    polygon += Vector(1.,0.,0.);
-    SphericalPointDistribution::Polygon_t newpolygon =
-        SPD.get<3>();
-    SphericalPointDistribution::Polygon_t expected = newpolygon;
-    expected.pop_front(); // remove first point
-    SphericalPointDistribution::Polygon_t remaining =
-        SphericalPointDistribution::matchSphericalPointDistributions(
-            polygon,
-            newpolygon);
-    CPPUNIT_ASSERT_EQUAL( expected, remaining );
-  }
-}
Index: src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
===================================================================
--- src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp	(revision f54930fdd572cf1e5e916da920bdad10f75cd695)
+++ 	(revision )
@@ -1,37 +1,0 @@
-/*
- * SphericalPointDistributionUnitTest.hpp
- *
- *  Created on: May 29, 2014
- *      Author: heber
- */
-
-#ifndef SPHERICALPOINTDISTRIBUTIONUNITTEST_HPP_
-#define SPHERICALPOINTDISTRIBUTIONUNITTEST_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include <cppunit/extensions/HelperMacros.h>
-
-/********************************************** Test classes **************************************/
-
-class SphericalPointDistributionTest : public CppUnit::TestFixture
-{
-    CPPUNIT_TEST_SUITE( SphericalPointDistributionTest) ;
-    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 );
-    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 );
-    CPPUNIT_TEST_SUITE_END();
-
-public:
-      void setUp();
-      void tearDown();
-      void matchSphericalPointDistributionsTest_2();
-      void matchSphericalPointDistributionsTest_3();
-
-private:
-};
-
-#endif /* SPHERICALPOINTDISTRIBUTIONUNITTEST_HPP_ */
