Index: molecuilder/src/builder.cpp
===================================================================
--- molecuilder/src/builder.cpp	(revision 978bcdd773c9e52917af746ae7197a083100b6b5)
+++ molecuilder/src/builder.cpp	(revision e49719da3aae43f0f717d5c7654d9c3a32cd8c99)
@@ -655,5 +655,5 @@
 static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
 {
-  atom *first, *second;
+  atom *first, *second, *third;
   molecule *mol = NULL;
   Vector x,y,z,n; // coordinates for absolute point in cell volume
@@ -667,4 +667,5 @@
   Log() << Verbose(0) << "r - remove an atom" << endl;
   Log() << Verbose(0) << "b - scale a bond between atoms" << endl;
+  Log() << Verbose(0) << "t - turn an atom round another bond" << endl;
   Log() << Verbose(0) << "u - change an atoms element" << endl;
   Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
@@ -746,4 +747,37 @@
         RemoveAtoms(mol);
       }
+      break;
+
+    case 't': // turn/rotate atom
+      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
+        if ((*ListRunner)->ActiveFlag) {
+          mol = *ListRunner;
+          Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl;
+          first = mol->AskAtom("Enter turning atom: ");
+          second = mol->AskAtom("Enter central atom: ");
+          third  = mol->AskAtom("Enter bond atom: ");
+          cout << Verbose(0) << "Enter new angle in degrees: ";
+          double tmp = 0.;
+          cin >> tmp;
+          // calculate old angle
+          x.CopyVector((const Vector *)&first->x);
+          x.SubtractVector((const Vector *)&second->x);
+          y.CopyVector((const Vector *)&third->x);
+          y.SubtractVector((const Vector *)&second->x);
+          double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
+          cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
+          cout << Verbose(0) << alpha << " degrees" << endl;
+          // rotate
+          z.MakeNormalVector(&x,&y);
+          x.RotateVector(&z,(alpha-tmp)*M_PI/180.);
+          x.AddVector(&second->x);
+          first->x.CopyVector(&x);
+          // check new angle
+          x.CopyVector((const Vector *)&first->x);
+          x.SubtractVector((const Vector *)&second->x);
+          alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
+          cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
+          cout << Verbose(0) << alpha << " degrees" << endl;
+        }
       break;
 
@@ -1413,5 +1447,5 @@
             Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl;
             Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
-            Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinStart> <BinEnd>\tPair Correlation analysis." << endl;
+            Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl;
             Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
             Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
@@ -1743,7 +1777,7 @@
                   case 'S':
                     {
-                      if ((argptr+5 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) {
+                      if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) {
                         ExitFlag = 255;
-                        eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output>" << endl;
+                        eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl;
                         performCriticalExit();
                       } else {
@@ -1751,6 +1785,7 @@
                         ofstream binoutput(argv[argptr+3]);
                         const double radius = 4.;
-                        const double BinStart = atof(argv[argptr+4]);
-                        const double BinEnd = atof(argv[argptr+5]);
+                        const double BinWidth = atof(argv[argptr+4]);
+                        const double BinStart = atof(argv[argptr+5]);
+                        const double BinEnd = atof(argv[argptr+6]);
                         double LCWidth = 20.;
                         if (BinEnd > 0) {
@@ -1792,5 +1827,5 @@
                           eLog() << Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl;
                         }
-                        BinPairMap *binmap = BinData( surfacemap, 0.5, BinStart, BinEnd );
+                        BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
                         OutputCorrelation ( &binoutput, binmap );
                         output.close();
@@ -1803,5 +1838,5 @@
                         delete(binmap);
                         delete(surfacemap);
-                        argptr+=6;
+                        argptr+=7;
                       }
                     }
