Merge branch 'master' into pygromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_bundle.cpp
similarity index 96%
rename from src/gromacs/gmxana/gmx_bundle.c
rename to src/gromacs/gmxana/gmx_bundle.cpp
index 8daa582b6bcab93ca971c8dc94fc543addc07df3..6d4eeffb0e3839511bbee596e1c4e450d4e1c12c 100644 (file)
@@ -36,8 +36,8 @@
  */
 #include "gmxpre.h"
 
-#include <math.h>
-#include <string.h>
+#include <cmath>
+#include <cstring>
 
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/confio.h"
@@ -94,6 +94,9 @@ static void calc_axes(rvec x[], t_atom atom[], int gnx[], atom_id *index[],
 
     snew(mtot, bun->n);
 
+    clear_rvec(axis[0]);
+    clear_rvec(axis[1]);
+
     for (end = 0; end < bun->nend; end++)
     {
         for (i = 0; i < bun->n; i++)
@@ -153,7 +156,7 @@ static void dump_axes(t_trxstatus *status, t_trxframe *fr, t_atoms *outat,
 {
     t_trxframe   frout;
     static rvec *xout = NULL;
-    int          i, end;
+    int          i;
 
     if (xout == NULL)
     {
@@ -217,7 +220,7 @@ int gmx_bundle(int argc, char *argv[])
         { "-z", FALSE, etBOOL, {&bZ},
           "Use the [IT]z[it]-axis as reference instead of the average axis" }
     };
-    FILE           *out, *flen, *fdist, *fz, *ftilt, *ftiltr, *ftiltl;
+    FILE           *flen, *fdist, *fz, *ftilt, *ftiltr, *ftiltl;
     FILE           *fkink = NULL, *fkinkr = NULL, *fkinkl = NULL;
     t_trxstatus    *status;
     t_trxstatus    *fpdb;
@@ -228,11 +231,10 @@ int gmx_bundle(int argc, char *argv[])
     t_trxframe      fr;
     t_atoms         outatoms;
     real            t, comp;
-    int             natoms;
     char           *grpname[MAX_ENDS], title[256];
     /* FIXME: The constness should not be cast away */
     char           *anm = (char *)"CA", *rnm = (char *)"GLY";
-    int             i, j, gnx[MAX_ENDS];
+    int             i, gnx[MAX_ENDS];
     atom_id        *index[MAX_ENDS];
     t_bundle        bun;
     gmx_bool        bKink;
@@ -377,10 +379,10 @@ int gmx_bundle(int argc, char *argv[])
             fprintf(ftilt, " %6g", RAD2DEG*acos(bun.dir[i][ZZ]));
             comp = bun.mid[i][XX]*bun.dir[i][XX]+bun.mid[i][YY]*bun.dir[i][YY];
             fprintf(ftiltr, " %6g", RAD2DEG*
-                    asin(comp/sqrt(sqr(comp)+sqr(bun.dir[i][ZZ]))));
+                    std::asin(comp/std::sqrt(sqr(comp)+sqr(bun.dir[i][ZZ]))));
             comp = bun.mid[i][YY]*bun.dir[i][XX]-bun.mid[i][XX]*bun.dir[i][YY];
             fprintf(ftiltl, " %6g", RAD2DEG*
-                    asin(comp/sqrt(sqr(comp)+sqr(bun.dir[i][ZZ]))));
+                    std::asin(comp/std::sqrt(sqr(comp)+sqr(bun.dir[i][ZZ]))));
             if (bKink)
             {
                 rvec_sub(bun.end[0][i], bun.end[2][i], va);
@@ -392,11 +394,11 @@ int gmx_bundle(int argc, char *argv[])
                 copy_rvec(bun.mid[i], vr);
                 vr[ZZ] = 0;
                 unitv_no_table(vr, vr);
-                fprintf(fkinkr, " %6g", RAD2DEG*asin(iprod(vc, vr)));
+                fprintf(fkinkr, " %6g", RAD2DEG*std::asin(iprod(vc, vr)));
                 vl[XX] = vr[YY];
                 vl[YY] = -vr[XX];
                 vl[ZZ] = 0;
-                fprintf(fkinkl, " %6g", RAD2DEG*asin(iprod(vc, vl)));
+                fprintf(fkinkl, " %6g", RAD2DEG*std::asin(iprod(vc, vl)));
             }
         }
         fprintf(flen, "\n");