#include #include "io_RT.h" /* ======= */ void getlmn_(double *x, double *y, double *z) /* ======= */ { fprintf (stderr, "getlmn_ called: this code needs to be fixed...\n"); assert (false); } /* ============= */ void VerboseDumpRT(double ** RotMat, double * TVect, double rms) /* ============= */ { double kappa ; double axis[4]; printf(" [ %7.4f %7.4f %7.4f ] [ %9.4f ]\n", RotMat[1][1],RotMat[1][2],RotMat[1][3],TVect[1]); printf("R = [ %7.4f %7.4f %7.4f ] T = [ %9.4f ]\n", RotMat[2][1],RotMat[2][2],RotMat[2][3],TVect[2]); printf(" [ %7.4f %7.4f %7.4f ] [ %9.4f ]\n", RotMat[3][1],RotMat[3][2],RotMat[3][3],TVect[3]); printf("\nRMS = %7.4f\n",rms); # ifdef OFF XPLORMATPRI(RotMat); # endif getlmn_(nr33tofort(RotMat),&kappa,&axis[1]); printf("Rotation of %7.4f about axis ( %7.4f %7.4f %7.4f )\n", kappa,axis[1],axis[2],axis[3]); } /* ============ */ double ** Get3x3Matrix(FILE * stream, char * string, char * TheDefault) /* ============ */ { # define WHOLE_ARRAY(M) \ M[1][1],M[1][2],M[1][3],\ M[2][1],M[2][2],M[2][3],\ M[3][1],M[3][2],M[3][3] # define SPC31 " " double ** M = dmatrix(1,3,1,3); char * fmt = "%lg%lg%lg%lg%lg%lg%lg%lg%lg" ; char * from ; if (stream != NULL) { from = "a stream" ; if (fscanf(stream,fmt,WHOLE_ARRAY(&M)) != 9) return Get3x3Matrix(NULL,string,TheDefault); } else if (string != NULL) { from = "a string" ; if (sscanf(string,fmt,WHOLE_ARRAY(&M)) != 9) return Get3x3Matrix(stream,NULL,TheDefault); } else { from = "the default" ; sscanf(TheDefault,fmt,WHOLE_ARRAY(&M)); } fmt = "[Got 3x3 from %12s] " "( %7.4f %7.4f %7.4f )\n" SPC31 "( %7.4f %7.4f %7.4f )\n" SPC31 "( %7.4f %7.4f %7.4f )\n" ; fprintf(stderr,fmt,from,WHOLE_ARRAY(M)); return M ; # undef WHOLE_ARRAY # undef SPC31 } /* ============ */ double * GetXYZVector(FILE * stream, char * string, char * TheDefault) /* ============ */ { # define WHOLE_ARRAY(M) \ M[1],M[2],M[3] double * M = dvector(1,3); char * fmt = "%lg%lg%lg" ; char * from ; if (stream != NULL) { from = "a stream" ; if (fscanf(stream,fmt,WHOLE_ARRAY(&M)) != 3) return GetXYZVector(NULL,string,TheDefault); } else if (string != NULL) { from = "a string" ; if (sscanf(string,fmt,WHOLE_ARRAY(&M)) != 3) return GetXYZVector(stream,NULL,TheDefault); } else { from = "the default" ; sscanf(TheDefault,fmt,WHOLE_ARRAY(&M)); } fmt = "[Got 3x1 from %12s] " "( %7.4f %7.4f %7.4f )\n" ; fprintf(stderr,fmt,from,WHOLE_ARRAY(M)); return (double *) M ; # undef WHOLE_ARRAY }