GLYLIB
0.3.0b
|
00001 /***Function written By Spandana Makeneni 2010***/ 00002 #include<mylib.h> 00003 #include<molecules.h> 00004 /***This defines the average plane for an array of coordinates according to puckering paramaters***/ 00005 00006 plane get_plane_for_ring(int n,coord_3D **r){ 00007 int jval[n]; 00008 int l; 00009 plane pval;//plane for returning the values of plane 00010 vectormag_3D Rj,Rcos,Rsin,R1,R2,R1xR2,avg_coord; 00011 R1.i=R1.j=R1.k=R2.i=R2.j=R2.k=0; 00012 avg_coord.i=avg_coord.j=avg_coord.k=0; 00013 for(l=0;l<n;l++){ 00014 jval[l]=l+1;//getting j vals for further equations 00015 } 00016 for(l=0;l<n;l++){//for loop for calculating the Rj vals 00017 Rj.i= r[l][0].i; 00018 Rj.j= r[l][0].j; 00019 Rj.k= r[l][0].k; 00020 Rsin.i = (Rj.i*sin(2*PI*(jval[l]-1)/n)); 00021 Rsin.j = (Rj.j*sin(2*PI*(jval[l]-1)/n)); 00022 Rsin.k = (Rj.k*sin(2*PI*(jval[l]-1)/n)); 00023 Rcos.i = (Rj.i*cos(2*PI*(jval[l]-1)/n)); 00024 Rcos.j = (Rj.j*cos(2*PI*(jval[l]-1)/n)); 00025 Rcos.k = (Rj.k*cos(2*PI*(jval[l]-1)/n)); 00026 R1.i=R1.i+Rsin.i; 00027 R1.j=R1.j+Rsin.j; 00028 R1.k=R1.k+Rsin.k; 00029 R2.i=R2.i+Rcos.i; 00030 R2.j=R2.j+Rcos.j; 00031 R2.k=R2.k+Rcos.k; 00032 } 00033 R1xR2 = get_crossprod(R1,R2);//cross prod of Rjs 00034 //printf("the R1xR2 is %f %f %f %f\n",R1xR2.i,R1xR2.j,R1xR2.k,R1xR2.d); 00035 //printf("the R1val is %f %f\n",R1.i,R2.i); 00036 //printf("the R2val is %f %f\n",R1.j,R2.j); 00037 //printf("the R3val is %f %f\n",R1.k,R2.k); 00038 pval.A = (R1xR2.i/R1xR2.d); 00039 pval.B = (R1xR2.j/R1xR2.d); 00040 pval.C = (R1xR2.k/R1xR2.d); 00041 for(l=0;l<n;l++){//for loop for calculating the avg x,y,z coordinates 00042 avg_coord.i=avg_coord.i+r[l][0].i; 00043 avg_coord.j=avg_coord.j+r[l][0].j; 00044 avg_coord.k=avg_coord.k+r[l][0].k; 00045 } 00046 avg_coord.i=(avg_coord.i/n); 00047 avg_coord.j=(avg_coord.j/n); 00048 avg_coord.k=(avg_coord.k/n); 00049 //printf("the avg coords are %f %f %f\n",avg_coord.i,avg_coord.j,avg_coord.k); 00050 pval.D= -(pval.A*avg_coord.i+pval.B*avg_coord.j+pval.C*avg_coord.k); 00051 //printf("the dval is %f\n",pval.D); 00052 00053 return pval; 00054 00055 }