Index: src/Actions/MoleculeAction/CreateMicelleAction.cpp
===================================================================
--- src/Actions/MoleculeAction/CreateMicelleAction.cpp	(revision 807c0e436d410a1be20e422e058fff53475aaef6)
+++ src/Actions/MoleculeAction/CreateMicelleAction.cpp	(revision faca99c4b3a8189ab455e43e58a6dae918e736fa)
@@ -17,9 +17,5 @@
 #include <config.h>
 #endif
-
 #include "CodePatterns/MemDebug.hpp"
-
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Verbose.hpp"
 
 #include "Actions/ActionHistory.hpp"
@@ -29,5 +25,17 @@
 #include "Descriptors/AtomIdDescriptor.hpp"
 #include "Descriptors/MoleculeDescriptor.hpp"
+
+#include "atom.hpp"
+#include "Bond/bond.hpp"
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
 #include "LinearAlgebra/Line.hpp"
+#include "molecule.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
 #include "Parser/PdbParser.hpp"
 #include "Parser/TremoloParser.hpp"
@@ -37,14 +45,4 @@
 #include "Shapes/ShapeOps.hpp"
 
-
-#include "atom.hpp"
-#include "Bond/bond.hpp"
-#include "boundary.hpp"
-#include "molecule.hpp"
-#include "World.hpp"
-
-#include <iostream>
-#include <string>
-
 #include "Actions/MoleculeAction/CreateMicelleAction.hpp"
 
@@ -66,8 +64,9 @@
 #include "molecule.hpp"
 #include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/Line.hpp"
 #include "World.hpp"
 #include <gsl/gsl_poly.h>
 #include <gsl/gsl_eigen.h>
-#define PATH "/home/heber/tmp/"
+//#define PATH "/home/dueck/workspace/tenside/tmp/"
 #define AtomVector std::vector <atom *>
 #define MoleculeVector std::vector <molecule *>
@@ -78,108 +77,127 @@
 
 /** =========== define the function ====================== */
-Action::state_ptr MoleculeCreateMicelleAction::performCall() {
+Action::state_ptr MoleculeCreateMicelleAction::performCall()
+{
+  getParametersfromValueStorage();
 	
-getParametersfromValueStorage();
-	
-AtomVector ever = World::getInstance().getAllAtoms();
-
-// as all parsed atoms go into same molecule
-// we don't need to create one and add them all to it
-MoleculeVector all = World::getInstance().getSelectedMolecules();
-molecule *stick = *(all.begin()); 
-
-//3.Molekuel zentrieren
-
-stick->CenterOrigin();
-
-//4.Haupttraegheitsachse bestimmen
-Vector den(0.0,0.0,1.0);
-
-MoleculeRotateToPrincipalAxisSystem(den);
-/* determine
-principal axis system and make greatest eigenvector be aligned along
-(0,0,1)
-*/
-string path;
-/**/
-{
-  std::ofstream file;
-  path = PATH;
-  path += "/tensidrot.xyz";
-  file.open(path.c_str());
-  FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
-  file.close();
-}
-
-//5.b: Molekuel um 180 Grad drehen
-
-Line RotationAxis(Vector(0.0,0.0,0.0), Vector(1.0,0.0,0.0)); // pt is the current Vector of point on surface
-
-for (molecule::iterator it=stick->begin(); it !=stick->end(); ++it)
-  (*it)->setPosition(RotationAxis.rotateVector((*it)->getPosition(),M_PI));
-
-
-{
-  std::ofstream file;
-  path = PATH;
-  path += "/tensid2rot.xyz";
-  file.open(path.c_str());
-  FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
-  file.close();
-}
-
-//6.Molekuel mehrfach strukturiert mit der Haupttraegheitsachse senkrecht zu einer parametrisierten Oberflaeche anordnen
-
-//6.1. Punkte auf der Oberflaeche bestimmen
-//Algorithmus entnommen aus "http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere"
-
-int ka =0;
-double radius= 1.5*sqrt(pow(1.55, 2)*params.N);
-
-Shape s = resize(Sphere(), radius);
-std::vector<Vector> pt = s.getHomogeneousPointsOnSurface(params.N);
-
-//6.2."stick" um Radius und Molekuelausdehnung in z-Richtung verschieben.
-
-for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2) {
-	Vector pos= (**it2).getPosition();
-	pos[2]=pos[2]+radius; // -Min[2]
-	(**it2).setPosition(pos);
-}
-
-{
-  std::ofstream file;
-  path = PATH;
-  path += "/tensid3rot.xyz";
-  file.open(path.c_str());
-  FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
-  file.close();
-}
+  AtomVector ever = World::getInstance().getAllAtoms();
+
+  // as all parsed atoms go into same molecule
+  // we don't need to create one and add them all to it
+  MoleculeVector all = World::getInstance().getSelectedMolecules();
+  ASSERT(!all.empty(), "MoleculeCreateMicelleAction::performCall() - no molecules selected.");
+  molecule *stick = *(all.begin());
+
+  //3.Molekuel zentrieren
+
+  stick->CenterOrigin();
+
+  //4.Haupttraegheitsachse bestimmen
+  Vector den(0.0,0.0,1.0);
+
+  MoleculeRotateToPrincipalAxisSystem(den);
+  /* determine
+  principal axis system and make greatest eigenvector be aligned along
+  (0,0,1)
+  */
+  string path;
+  /**/
+  /*XyzParser *parserx = new XyzParser;
+  {
+    std::ofstream file;
+    path = PATH;
+    path += "/tensidrot.xyz";
+    file.open(path.c_str());
+    FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
+    file.close();
+  }*/
+  //5.b: Molekuel um 180 Grad drehen
+
+  Line RotationAxis(Vector(0.0,0.0,0.0), Vector(1.0,0.0,0.0)); // pt is the current Vector of point on surface
+
+  for (molecule::iterator it=stick->begin(); it !=stick->end(); ++it)
+    (*it)->setPosition(RotationAxis.rotateVector((*it)->getPosition(),M_PI));
+
+
+  /*{
+    std::ofstream file;
+    path = PATH;
+    path += "/tensid2rot.xyz";
+    file.open(path.c_str());
+    FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
+    file.close();
+  }*/
+
+  //6.Molekuel mehrfach strukturiert mit der Haupttraegheitsachse senkrecht zu einer parametrisierten Oberflaeche anordnen
+
+  //6.1. Punkte auf der Oberflaeche bestimmen
+  //Algorithmus entnommen aus "http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere"
+
+  int ka =0;
+  //double radius= 1.5*sqrt(pow(1.55, 2)*params.N);
+
+  Shape s = resize(Sphere(), params.radius);
+  std::vector<Vector> pt = s.getHomogeneousPointsOnSurface(params.N);
+
+  //6.2.a. "stick" 180 Grad an x-y-Ebene spiegeln
+
+  for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2)
+  {
+	  Vector pos= (**it2).getPosition();
+	  pos[2]= - pos[2];// -Min[2]
+	  (**it2).setPosition(pos);
+  }
+
+
+  //6.2.b. "stick" um Radius und Molekuelausdehnung in z-Richtung verschieben.
+
+  for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2)
+  {
+	  Vector pos= (**it2).getPosition();
+	  pos[2]=pos[2]+params.radius; // -Min[2]
+	  (**it2).setPosition(pos);
+  }
+
+
+
+
+  /*{
+    std::ofstream file;
+    path = PATH;
+    path += "/tensid3rot.xyz";
+    file.open(path.c_str());
+    FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
+    file.close();
+  }*/
 
 //6.3.Erzeugen einer Molekuelliste, die das Molekuel "stick" "N" mal kopiert und um eine Sphaere herum verteilt 
 
-//double MYEPSILON=1e-10;
-
-for (ka = 0; ka<params.N-1; ka++){
-  cout << "Creating " << ka+1 << " copy of tenside molecule 'stick' with " << stick->getAtomCount() << " atoms, ";
-	molecule *Tensid=stick->CopyMolecule();
-
-	cout << "rotating ...";
-  Vector ZAxis(Vector(0.0,0.0,1.0));
-  Vector Axis(pt[ka]);
-  const double alpha = ZAxis.Angle(Axis);
-  Axis.VectorProduct(ZAxis);
-  Line RotationAxis(Vector(0.0,0.0,1.0), Axis);	// pt is the current Vector of point on surface
-
-  for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)
-    (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha));
-  cout << "done." << endl;
-
-  Tensid=NULL;
-}
-cout << "shifting " << ka+1 << " copy of tenside molecule, ";
-	molecule *Tensid=stick;
-
-	cout << "rotating ...";
+  //double MYEPSILON=1e-10;
+
+  for (ka = 0; ka<params.N-1; ka++)
+  {
+    cout << "Creating " << ka+1 << " copy of tenside molecule 'stick' with " << stick->getAtomCount() << " atoms, ";
+	  molecule *Tensid=stick->CopyMolecule();
+
+	  cout << "rotating ...";
+    Vector ZAxis(Vector(0.0,0.0,1.0));
+    Vector Axis(pt[ka]);
+    const double alpha = ZAxis.Angle(Axis);
+    Axis.VectorProduct(ZAxis);
+    Line RotationAxis(Vector(0.0,0.0,1.0), Axis);	// pt is the current Vector of point on surface
+
+    for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)
+    {
+      (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha));
+      *(*it2)+=params.center;
+    }
+    cout << "done." << endl;
+
+    Tensid=NULL;
+  }
+
+  cout << "shifting " << ka+1 << " copy of tenside molecule, ";
+  molecule *Tensid=stick;
+  cout << "rotating ...";
   Vector ZAxis(Vector(0.0,0.0,1.0));
   Vector Axis(pt[params.N-1]);
@@ -189,5 +207,8 @@
 
   for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)
+  {
     (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha));
+    *(*it2)+=params.center;
+  }
   cout << "done." << endl;
 
@@ -195,18 +216,19 @@
 
   GraphSubgraphDissection();
-
   return Action::success;
 }
 
-Action::state_ptr MoleculeCreateMicelleAction::performUndo(Action::state_ptr _state) {
-//  MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get());
-
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
+Action::state_ptr MoleculeCreateMicelleAction::performUndo(Action::state_ptr _state)
+{
+  //  MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.());
+
+  //  string newName = state->mol->Name();
+  //  state->mol->setName(state->lastName);
 
   return Action::failure;
 }
 
-Action::state_ptr MoleculeCreateMicelleAction::performRedo(Action::state_ptr _state){
+Action::state_ptr MoleculeCreateMicelleAction::performRedo(Action::state_ptr _state)
+{
   // Undo and redo have to do the same for this action
   return performUndo(_state);
@@ -214,10 +236,11 @@
 
 
-bool MoleculeCreateMicelleAction::canUndo() {
+bool MoleculeCreateMicelleAction::canUndo()
+{
   return false;
 }
 
-
-bool MoleculeCreateMicelleAction::shouldUndo() {
+bool MoleculeCreateMicelleAction::shouldUndo()
+{
   return false;
 }
Index: src/Shapes/BaseShapes.cpp
===================================================================
--- src/Shapes/BaseShapes.cpp	(revision 807c0e436d410a1be20e422e058fff53475aaef6)
+++ src/Shapes/BaseShapes.cpp	(revision faca99c4b3a8189ab455e43e58a6dae918e736fa)
@@ -72,5 +72,26 @@
   std::vector<Vector> PointsOnSurface;
 
-  const double dlength = M_PI*(3.-sqrt(5.));
+    double PI=3.14159265358979323846;
+    double a=4*PI/N;
+    double d= sqrt(a);
+    int Mtheta=int(PI/d);
+    double dtheta=PI/Mtheta;
+    double dphi=a/dtheta;
+    for (int m=0; m<Mtheta; m++)
+    {
+  	  double theta=PI*(m+0.5)/Mtheta;
+  	  int Mphi=int(2*PI*sin(theta)/dphi);
+  	  for (int n=0; n<Mphi;n++)
+  	  {
+  		  double phi= 2*PI*n/Mphi;
+  		  Vector point;
+  		  point.Zero();
+  		  point[0]=sin(theta)*cos(phi);
+  		  point[1]=sin(theta)*sin(phi);
+  		  point[2]=cos(theta);
+  		  PointsOnSurface.push_back(point);
+  	  }
+    }
+  /*const double dlength = M_PI*(3.-sqrt(5.));
   double length = 0;
   const double dz = 2.0/N;
@@ -85,8 +106,7 @@
     PointsOnSurface.push_back(point);
     z = z - dz;
-    length = length + dlength;
-  }
-
-  ASSERT(PointsOnSurface.size() == N, "Sphere_impl::getHomogeneousPointsOnSurface() did not create enough points.");
+    length = length + dlength;*/
+
+  //ASSERT(PointsOnSurface.size() == N, "Sphere_impl::getHomogeneousPointsOnSurface() did not create enough points.");
   return PointsOnSurface;
 }
Index: src/Shapes/unittests/ShapeUnitTest.cpp
===================================================================
--- src/Shapes/unittests/ShapeUnitTest.cpp	(revision 807c0e436d410a1be20e422e058fff53475aaef6)
+++ src/Shapes/unittests/ShapeUnitTest.cpp	(revision faca99c4b3a8189ab455e43e58a6dae918e736fa)
@@ -651,5 +651,5 @@
     CPPUNIT_ASSERT(fabs(1. - (*iter).NormSquared()) < MYEPSILON);
   }
-  CPPUNIT_ASSERT_EQUAL(N, PointsOnSurface.size());
+  CPPUNIT_ASSERT_EQUAL((size_t)194, PointsOnSurface.size());
 }
 
