From: hackbard Date: Mon, 5 May 2008 08:36:13 +0000 (+0200) Subject: centre atoms for visualization X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=506ec06909fab3aa57b6f75712aada8755f464e5;p=physik%2Fposic.git centre atoms for visualization --- diff --git a/visual_atoms.c b/visual_atoms.c index 9baa487..50507db 100644 --- a/visual_atoms.c +++ b/visual_atoms.c @@ -19,7 +19,8 @@ int usage(char *prog) { printf("\nusage:\n"); - printf(" %s [marked atom]\n\n",prog); + printf(" %s [marked atom]\n\n", + prog); return -1; } @@ -35,7 +36,9 @@ int main(int argc,char **argv) { t_linkcell *lc; t_3dvec dist; double d,radius; + double ox,oy,oz; int ma,ca; + double lac; if(argc<4) { usage(argv[0]); @@ -44,10 +47,11 @@ int main(int argc,char **argv) { ca=atoi(argv[2]); radius=atof(argv[3]); + lac=atof(argv[4]); ma=-1; - if(argc==5) - ma=atoi(argv[4]); + if(argc==6) + ma=atoi(argv[5]); memset(&moldyn,0,sizeof(t_moldyn)); @@ -71,9 +75,41 @@ int main(int argc,char **argv) { (itom->r.z+moldyn.dim.z/2)/lc->z, n); - + + /* prepare offset */ + ox=0.0; + if(itom->r.x<0) { + while((itom->r.x+ox)<(-lac/2.0)) + ox+=lac; + } + else { + while((itom->r.x+ox)>(lac/2.0)) + ox-=lac; + } + + oy=0.0; + if(itom->r.y<0) { + while((itom->r.y+oy)<(-lac/2.0)) + oy+=lac; + } + else { + while((itom->r.y+oy)>(lac/2.0)) + oy-=lac; + } + + oz=0.0; + if(itom->r.z<0) { + while((itom->r.z+oz)<(-lac/2.0)) + oz+=lac; + } + else { + while((itom->r.z+oz)>(lac/2.0)) + oz-=lac; + } + + printf("%s %f %f %f %s %f\n", - pse_name[itom->element],itom->r.x,itom->r.y,itom->r.z, + pse_name[itom->element],itom->r.x+ox,itom->r.y+oy,itom->r.z+oz, "Green",itom->ekin); for(j=0;j<27;j++) { @@ -97,7 +133,7 @@ int main(int argc,char **argv) { if(d<=radius) { printf("%s %f %f %f %s %f\n", pse_name[jtom->element], - jtom->r.x,jtom->r.y,jtom->r.z, + jtom->r.x+ox,jtom->r.y+oy,jtom->r.z+oz, (jtom->tag==ma)?"Red":pse_col[jtom->element], jtom->ekin); }