]> hackdaworld.org Git - physik/posic.git/commitdiff
centre atoms for visualization
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Mon, 5 May 2008 08:36:13 +0000 (10:36 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Mon, 5 May 2008 08:36:13 +0000 (10:36 +0200)
visual_atoms.c

index 9baa487de4835464b45ea874c533f8a04224378b..50507db5c155947105e76d24c11314193a7803d4 100644 (file)
@@ -19,7 +19,8 @@
 int usage(char *prog) {
 
        printf("\nusage:\n");
-       printf("  %s <file> <centre atom> <radius> [marked atom]\n\n",prog);
+       printf("  %s <file> <centre atom> <radius> <lc> [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);
                        }