GLYLIB  0.3.0b
translate_zero_to_coord.c
Go to the documentation of this file.
00001 // Function written by B. Lachele Foley, 2007
00002 #include <mylib.h>
00003 #include <molecules.h>
00004 //#include "../inc/mylib.h"
00005 //#include "../inc/molecules.h"
00006 /****************** translate_zero_to_coord_M() *********************/
00007 /* Translates the specifiec coords (location xs) so that the coordinate
00008 indicated by c is at the origin.  Places the translated coords in xt. */
00009 
00010 // START HERE -- integrate or retire this ASAP
00011 
00012 void translate_zero_to_coord_M(molecule *m,int xs,int xt,coord_3D c){
00013 int ta=0,tb,tuse=0,tsz=0,tbins=0;
00014 
00015 // move center of mass to specified location
00016 if((xs==-1)&&(xt==-1)){
00017         for(ta=0;ta<m[0].nr;ta++){ 
00018                 for(tb=0;tb<m[0].r[ta].na;tb++){ 
00019                         m[0].r[ta].a[tb].x=subtract_coord(m[0].r[ta].a[tb].x,c);
00020                         }
00021                 }
00022         }
00023 if((xs!=-1)&&(xt==-1)){
00024         for(ta=0;ta<m[0].nr;ta++){ 
00025                 for(tb=0;tb<m[0].r[ta].na;tb++){ 
00026                         tuse=malloc_usable_size(m[0].r[ta].a[tb].xa);
00027                         tsz=sizeof(coord_3D);
00028                         tbins=tuse/tsz; 
00029                         if(tbins<(xs+1)){mywhine("memory issue: source coords (1) not allocated in translate_zero_to_coord");}
00030                         m[0].r[ta].a[tb].x=subtract_coord(m[0].r[ta].a[tb].xa[xs],c);
00031                         }
00032                 }
00033         }
00034 if((xs==-1)&&(xt!=-1)){
00035         for(ta=0;ta<m[0].nr;ta++){ 
00036                 for(tb=0;tb<m[0].r[ta].na;tb++){ 
00037                         tuse=malloc_usable_size(m[0].r[ta].a[tb].xa);
00038                         tsz=sizeof(coord_3D);
00039                         tbins=tuse/tsz; 
00040                         if(tbins<(xt+1)){mywhine("memory issue: translated coords (1) not allocated in translate_zero_to_coord");}
00041                         m[0].r[ta].a[tb].xa[xt]=subtract_coord(m[0].r[ta].a[tb].x,c);
00042                         }
00043                 }
00044         }
00045 if((xs!=-1)&&(xt!=-1)){
00046         for(ta=0;ta<m[0].nr;ta++){ 
00047                 for(tb=0;tb<m[0].r[ta].na;tb++){ 
00048                         tuse=malloc_usable_size(m[0].r[ta].a[tb].xa);
00049                         tsz=sizeof(coord_3D); 
00050                         tbins=tuse/tsz; 
00051                         if(tbins<(xs+1)){mywhine("memory issue: source coords (2) not allocated in translate_zero_to_coord");}
00052                         if(tbins<(xt+1)){mywhine("memory issue: translated coords (2) not allocated in translate_zero_to_coord");}
00053                         m[0].r[ta].a[tb].xa[xt]=subtract_coord(m[0].r[ta].a[tb].xa[xs],c);
00054                         }
00055                 }
00056         }
00057 return;
00058 }
 All Classes Files Functions Variables Typedefs Defines