GLYLIB
0.3.0b
|
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 /************** get_ring_center() ******************/ 00007 /* this finds the center point for a set of atoms. 00008 c is a pointer to a list of nc coord_3D sets */ 00009 coord_3D get_geometric_center(coord_3D *c,int nc){ 00010 int gca=0; 00011 coord_3D C; 00012 00013 if(nc==0){mywhine("cannot get center for zero points (get_geometric_center)");} 00014 C.i=C.j=C.k=0; 00015 //printf("initialized:\n"); 00016 //dprint_coord_3D(&C); 00017 //printf("in loop:\n"); 00018 for(gca=0;gca<nc;gca++){ 00019 // X.i (center) = avg (atomscoords.x.i) ; and so forth 00020 C.i+=c[gca].i; 00021 C.j+=c[gca].j; 00022 C.k+=c[gca].k; 00023 //dprint_coord_3D(&C); 00024 } 00025 C.i/=nc; 00026 C.j/=nc; 00027 C.k/=nc; 00028 //printf("done:\n"); 00029 //dprint_coord_3D(&C); 00030 return C; 00031 } 00032 /* This is just like get_geometric_center except it expects an array 00033 of double pointers. Uses less memory when referring to coordinates 00034 within the larger structures. Each pointer in the array should 00035 point to a coordinate to be used in the calculation. */ 00036 coord_3D get_geometric_center_dp(coord_3D **c,int nc){ 00037 int gca=0; 00038 coord_3D C; 00039 00040 if(nc==0){mywhine("cannot get center for zero points (get_geometric_center)");} 00041 C.i=C.j=C.k=0; 00042 //printf("initialized:\n"); 00043 //dprint_coord_3D(&C); 00044 //printf("in loop:\n"); 00045 for(gca=0;gca<nc;gca++){ 00046 // X.i (center) = avg (atomscoords.x.i) ; and so forth 00047 C.i+=c[gca][0].i; 00048 C.j+=c[gca][0].j; 00049 C.k+=c[gca][0].k; 00050 //dprint_coord_3D(&C); 00051 } 00052 C.i/=nc; 00053 C.j/=nc; 00054 C.k/=nc; 00055 //printf("done:\n"); 00056 //dprint_coord_3D(&C); 00057 return C; 00058 } 00059