ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/xyz2pov/src/xyz2pov.c
(Generate patch)

Comparing trunk/xyz2pov/src/xyz2pov.c (file contents):
Revision 515 by mmeineke, Thu May 1 17:36:33 2003 UTC vs.
Revision 1095 by mmeineke, Mon Apr 5 19:34:21 2004 UTC

# Line 1 | Line 1
1 + #define _FILE_OFFSET_BITS 64
2 +
3   #include <stdio.h>
4   #include <stdlib.h>
5   #include <string.h>
# Line 16 | Line 18 | struct linked_xyz{
18  
19   struct linked_xyz{
20    struct coords *r;
21 <  double boxX, boxY, boxZ;
21 >  double Hmat[3][3];
22    struct linked_xyz *next;
23   };
24  
# Line 24 | Line 26 | int draw_atoms = 0; /*boolean to draw atoms */
26   int draw_bonds = 0; /* boolean to draw bonds or not */
27   int draw_hydrogens = 0; /*boolean to draw hydrogens */
28   int draw_atoms = 0; /*boolean to draw atoms */
29 + int draw_vectors = 0; /*boolean to draw vectors */
30   int draw_box = 0;  // boolean to draw the periodic Box
31   int regenerateBonds = 0; // boolean to regenearate bonds each frame
32  
33   void usage(void);
34 + int count_tokens(char *line, char *delimiters);
35  
36   int main(argc, argv)
37       int argc;
# Line 37 | Line 41 | int main(argc, argv)
41  
42    struct coords *out_coords;
43  
44 <  int i,j; /* loop counters */
44 >  int i,j,k; /* loop counters */
45    mode_t dir_mode = S_IRWXU;
46  
47    int generate_header = 0; /* boolean for generating the pov ray header */
# Line 47 | Line 51 | int main(argc, argv)
51    double small_x = 0;
52    double small_y = 0; /* lets me know the smallest x, y, z */
53    double small_z = 0;
54 +  int extremaSet = 0;
55    double rsqr; /* the square of the diagonal */
56    double diagonal; /* the diagonal length of the sim box */
57  
58    unsigned int n_atoms; /*the number of atoms in each time step */
59 <  char read_buffer[120]; /*the line buffer for reading */
59 >  char read_buffer[2000]; /*the line buffer for reading */
60    char *eof_test; /*ptr to see when we reach the end of the file */
61    char *foo; /*the pointer to the current string token */
62    FILE *in_file; /* the input file */
# Line 66 | Line 71 | int main(argc, argv)
71    char current_flag;
72    int nFrames;
73    int nZeroes;
74 +  int nTokens;
75    double count;
76  
77    int startFrame = 1;
# Line 79 | Line 85 | int main(argc, argv)
85    
86    unsigned int n_interpolate = 0; /* number of frames to interpolate */
87    double dx, dy, dz; /* temp variables for interpolating distances */
88 +  double dm[3][3];
89    
90  
91    char pov_dir[500]; /* the pov_dir */
# Line 179 | Line 186 | int main(argc, argv)
186              // -a => draw the atoms
187  
188              draw_atoms = 1;
189 +            break;
190 +
191 +          case 'v':
192 +            // -v => draw the vectors
193 +
194 +            draw_vectors = 1;
195              break;
196  
197            case 'r':
# Line 270 | Line 283 | int main(argc, argv)
283      out_prefix = strtok(in_name, ".");
284    }
285  
286 <  sprintf( out_format, "%s%s%%0%dd.pov", pov_dir, out_prefix, nZeroes );
286 >  sprintf( out_format, "%s%s-%%0%dd.pov", pov_dir, out_prefix, nZeroes );
287  
288    // start reading the first frame
289  
# Line 302 | Line 315 | int main(argc, argv)
315      if( draw_box ){
316        foo = strtok(read_buffer, " ,;\t");
317        if(foo == NULL){
318 <        printf("error in reading file\n");
318 >        printf("error in reading file time\n");
319          exit(8);
320        }
321        
322        foo = strtok(NULL, " ,;\t");
323        if(foo == NULL){
324 <        printf("error in reading file\n");
324 >        printf("error in reading file h00\n");
325          exit(8);
326        }
327 <      current_frame->boxX = atof( foo );
327 >      current_frame->Hmat[0][0] = atof( foo );
328  
329        foo = strtok(NULL, " ,;\t");
330        if(foo == NULL){
331 <        printf("error in reading file\n");
331 >        printf("error in reading file h10\n");
332          exit(8);
333        }
334 <      current_frame->boxY = atof( foo );
334 >      current_frame->Hmat[1][0] = atof( foo );
335  
336        foo = strtok(NULL, " ,;\t");
337        if(foo == NULL){
338 <        printf("error in reading file\n");
338 >        printf("error in reading file h20\n");
339          exit(8);
340        }
341 <      current_frame->boxZ = atof( foo );
329 <    }
341 >      current_frame->Hmat[2][0] = atof( foo );
342  
343 <    for( i=0; i < n_atoms; i++){
344 <      
345 <      eof_test = fgets(read_buffer, sizeof(read_buffer), in_file);
334 <      if(eof_test == NULL){
335 <        printf("error in reading file\n");
343 >      foo = strtok(NULL, " ,;\t");
344 >      if(foo == NULL){
345 >        printf("error in reading file h01\n");
346          exit(8);
347        }
348 +      current_frame->Hmat[0][1] = atof( foo );
349  
350 <      foo = strtok(read_buffer, " ,;\t");
350 >      foo = strtok(NULL, " ,;\t");
351        if(foo == NULL){
352 <        printf("error in reading file\n");
352 >        printf("error in reading file h11\n");
353          exit(8);
354        }
355 <      (void)strcpy(current_frame->r[i].name, foo); /*copy the atom name */
355 >      current_frame->Hmat[1][1] = atof( foo );
356  
346      /* next we grab the positions */
347      
357        foo = strtok(NULL, " ,;\t");
358        if(foo == NULL){
359 <        printf("error in reading file\n");
359 >        printf("error in reading file h21\n");
360          exit(8);
361        }
362 <      (void)sscanf(foo, "%lf",&current_frame->r[i].x);
363 <      if(current_frame->r[i].x > big_x) big_x = current_frame->r[i].x;
355 <      if(current_frame->r[i].x < small_x) small_x = current_frame->r[i].x;
356 <            
357 <  
362 >      current_frame->Hmat[2][1] = atof( foo );
363 >
364        foo = strtok(NULL, " ,;\t");
365        if(foo == NULL){
366 <        printf("error in reading file\n");
366 >        printf("error in reading file h02\n");
367 >        exit(8);
368 >      }
369 >      current_frame->Hmat[0][2] = atof( foo );
370 >
371 >      foo = strtok(NULL, " ,;\t");
372 >      if(foo == NULL){
373 >        printf("error in reading file h12\n");
374          exit(8);
375        }
376 <      (void)sscanf(foo, "%lf", &current_frame->r[i].y);
364 <      if(current_frame->r[i].y > big_y) big_y = current_frame->r[i].y;
365 <      if(current_frame->r[i].y < small_y) small_y = current_frame->r[i].y;
376 >      current_frame->Hmat[1][2] = atof( foo );
377  
367
378        foo = strtok(NULL, " ,;\t");
379        if(foo == NULL){
380 <        printf("error in reading file\n");
380 >        printf("error in reading file h22\n");
381          exit(8);
382        }
383 +      current_frame->Hmat[2][2] = atof( foo );
384 +
385 +    }
386 +
387 +    for( i=0; i < n_atoms; i++){
388 +      
389 +      eof_test = fgets(read_buffer, sizeof(read_buffer), in_file);
390 +      if(eof_test == NULL){
391 +        printf("error in reading file line at atom %d\n", i);
392 +        exit(8);
393 +      }
394 +
395 +      nTokens = count_tokens(read_buffer, " ,;\t");
396 +
397 +      if (nTokens < 4) {
398 +        printf("Not enough tokens while parsing file at atom %d\n", i);
399 +        exit(8);
400 +      }
401 +
402 +      foo = strtok(read_buffer, " ,;\t");
403 +      (void)strcpy(current_frame->r[i].name, foo); /*copy the atom name */
404 +
405 +      foo = strtok(NULL, " ,;\t");
406 +      (void)sscanf(foo, "%lf",&current_frame->r[i].x);
407 +      foo = strtok(NULL, " ,;\t");
408 +      (void)sscanf(foo, "%lf", &current_frame->r[i].y);
409 +      foo = strtok(NULL, " ,;\t");
410        (void)sscanf(foo, "%lf", &current_frame->r[i].z);
374      if(current_frame->r[i].z > big_z) big_z = current_frame->r[i].z;
375      if(current_frame->r[i].z < small_z) small_z = current_frame->r[i].z;
411  
412 +      if (extremaSet) {
413 +        if(current_frame->r[i].x > big_x) big_x = current_frame->r[i].x;
414 +        if(current_frame->r[i].x < small_x) small_x = current_frame->r[i].x;
415 +        
416 +        if(current_frame->r[i].y > big_y) big_y = current_frame->r[i].y;
417 +        if(current_frame->r[i].y < small_y) small_y = current_frame->r[i].y;
418 +        
419 +        if(current_frame->r[i].z > big_z) big_z = current_frame->r[i].z;
420 +        if(current_frame->r[i].z < small_z) small_z = current_frame->r[i].z;
421 +      } else {
422 +        big_x = current_frame->r[i].x;
423 +        small_x = current_frame->r[i].x;
424 +        
425 +        big_y = current_frame->r[i].y;
426 +        small_y = current_frame->r[i].y;
427 +        
428 +        big_z = current_frame->r[i].z;
429 +        small_z = current_frame->r[i].z;
430 +
431 +        extremaSet = 1;
432 +
433 +      }
434 +
435 +      if (nTokens == 5 || nTokens > 7) {
436 +        foo = strtok(NULL, " ,;\t");
437 +        (void)sscanf(foo, "%lf", &current_frame->r[i].charge);
438 +        current_frame->r[i].hasCharge = 1;
439 +      } else {
440 +        current_frame->r[i].hasCharge = 0;
441 +      }
442 +
443 +      
444 +      if (nTokens >= 7) {
445 +        foo = strtok(NULL, " ,;\t");
446 +        (void)sscanf(foo, "%lf", &current_frame->r[i].ux);
447 +        foo = strtok(NULL, " ,;\t");
448 +        (void)sscanf(foo, "%lf", &current_frame->r[i].uy);
449 +        foo = strtok(NULL, " ,;\t");
450 +        (void)sscanf(foo, "%lf", &current_frame->r[i].uz);
451 +        current_frame->r[i].hasVector = 1;
452 +      } else {
453 +        current_frame->r[i].hasVector = 0;
454 +      }
455      }
456      currentCount++;
457      
# Line 401 | Line 479 | int main(argc, argv)
479                          "#include \"pov_header.pov\"\n"
480                          "\n");
481            if( draw_box ){
482 <            dx = current_frame->boxX - temp_frame->boxX;
483 <            dy = current_frame->boxY - temp_frame->boxY;
484 <            dz = current_frame->boxZ - temp_frame->boxZ;
485 <            
486 <            dx /= (double)(n_interpolate + 1);
487 <            dy /= (double)(n_interpolate + 1);
488 <            dz /= (double)(n_interpolate + 1);
489 <            
482 >
483 >            for (j = 0; j < 3; j++) {
484 >              for (k = 0; k < 3; k++) {
485 >                dm[j][k] = current_frame->Hmat[j][k] - temp_frame->Hmat[j][k];
486 >                dm[j][k] /= (double)(n_interpolate + 1);
487 >              }
488 >            }
489 >                            
490              fprintf( out_file,
491 <                     "makePeriodicBox( %lf, %lf, %lf )\n"
491 >                     "makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf)\n"
492                       "\n",
493 <                     temp_frame->boxX + dx * (i+1),
494 <                     temp_frame->boxZ + dz * (i+1),
495 <                     temp_frame->boxY + dy * (i+1) );
493 >                     temp_frame->Hmat[0][0] + dm[0][0] * (i+1),
494 >                     temp_frame->Hmat[2][0] + dm[2][0] * (i+1),
495 >                     temp_frame->Hmat[1][0] + dm[1][0] * (i+1),
496 >                     temp_frame->Hmat[0][1] + dm[0][1] * (i+1),
497 >                     temp_frame->Hmat[2][1] + dm[2][1] * (i+1),
498 >                     temp_frame->Hmat[1][1] + dm[1][1] * (i+1),
499 >                     temp_frame->Hmat[0][2] + dm[0][2] * (i+1),
500 >                     temp_frame->Hmat[2][2] + dm[2][2] * (i+1),
501 >                     temp_frame->Hmat[1][2] + dm[1][2] * (i+1) );
502            }
503            
504            
# Line 434 | Line 518 | int main(argc, argv)
518              out_coords[j].x = temp_frame->r[j].x + dx * (i+1);
519              out_coords[j].y = temp_frame->r[j].y + dy * (i+1);
520              out_coords[j].z = temp_frame->r[j].z + dz * (i+1);
521 +
522 +            if (current_frame->r[j].hasVector) {              
523 +              dx = current_frame->r[j].ux - temp_frame->r[j].ux;
524 +              dy = current_frame->r[j].uy - temp_frame->r[j].uy;
525 +              dz = current_frame->r[j].uz - temp_frame->r[j].uz;
526 +              
527 +              dx /= (double)(n_interpolate + 1);
528 +              dy /= (double)(n_interpolate + 1);
529 +              dz /= (double)(n_interpolate + 1);
530 +              
531 +              out_coords[j].hasVector = current_frame->r[j].hasVector;
532 +              out_coords[j].ux = temp_frame->r[j].ux + dx * (i+1);
533 +              out_coords[j].uy = temp_frame->r[j].uy + dy * (i+1);
534 +              out_coords[j].uz = temp_frame->r[j].uz + dz * (i+1);
535 +            }
536 +
537 +            if (current_frame->r[j].hasCharge) {              
538 +              dx = current_frame->r[j].charge - temp_frame->r[j].charge;
539 +              
540 +              dx /= (double)(n_interpolate + 1);
541 +              
542 +              out_coords[j].hasCharge = current_frame->r[j].hasCharge;
543 +              out_coords[j].charge = temp_frame->r[j].charge + dx * (i+1);
544 +            }
545 +
546            }
547            
548            pov_write(out_file, out_coords, n_atoms, draw_hydrogens, draw_bonds,
549 <                    draw_atoms);
549 >                    draw_atoms, draw_vectors);
550            free(out_coords);
551            (void)fclose(out_file);
552          }
# Line 461 | Line 570 | int main(argc, argv)
570        if( draw_box ){
571          
572          fprintf( out_file,
573 <                 "makePeriodicBox( %lf, %lf, %lf )\n"
573 >                 "makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf )\n"
574                   "\n",
575 <                 current_frame->boxX,
576 <                 current_frame->boxZ,
577 <                 current_frame->boxY );
575 >                 current_frame->Hmat[0][0],
576 >                 current_frame->Hmat[2][0],
577 >                 current_frame->Hmat[1][0],
578 >                 current_frame->Hmat[0][1],
579 >                 current_frame->Hmat[2][1],
580 >                 current_frame->Hmat[1][1],
581 >                 current_frame->Hmat[0][2],
582 >                 current_frame->Hmat[2][2],
583 >                 current_frame->Hmat[1][2] );
584        }
585        
586        
# Line 478 | Line 593 | int main(argc, argv)
593          out_coords[i].x = current_frame->r[i].x;
594          out_coords[i].y = current_frame->r[i].y;
595          out_coords[i].z = current_frame->r[i].z;
596 +
597 +        if (current_frame->r[i].hasVector) {              
598 +          out_coords[i].hasVector = current_frame->r[i].hasVector;
599 +          out_coords[i].ux = current_frame->r[i].ux;
600 +          out_coords[i].uy = current_frame->r[i].uy;
601 +          out_coords[i].uz = current_frame->r[i].uz;
602 +        }
603 +
604 +        if (current_frame->r[i].hasCharge) {              
605 +          out_coords[i].hasCharge = current_frame->r[i].hasCharge;
606 +          out_coords[i].charge = current_frame->r[i].charge;
607 +        }
608        }
609        pov_write(out_file, out_coords, n_atoms, draw_hydrogens, draw_bonds,
610 <                draw_atoms);
610 >                draw_atoms, draw_vectors);
611        free(out_coords);
612        
613        (void)fclose(out_file);
# Line 565 | Line 692 | int main(argc, argv)
692              "\n"
693              "#declare ATOM_SPHERE_FACTOR = 0.2;\n"
694              "#declare BOND_RADIUS = 0.1;\n"
695 +            "#declare VECTOR_SCALE = 1.0;\n"    
696 +            "#declare STICK_RADIUS = 0.5 * BOND_RADIUS;\n"
697 +            "#declare CONE_RADIUS = 2.0 * STICK_RADIUS;\n"
698 +            "#declare CONE_FRACTION = 0.15;\n"
699              "\n"
700              "// declare camera, light, and system variables\n"
701              "\n"
# Line 582 | Line 713 | int main(argc, argv)
713              "#declare cameraLookY = sysCenterY;\n"
714              "#declare cameraLookZ = sysCenterZ;\n"
715              "\n"
716 +            "#declare rotatePointX = cameraLookX;\n"
717 +            "#declare rotatePointY = cameraLookY;\n"
718 +            "#declare rotatePointZ = cameraLookZ;\n"
719 +            "\n"
720              "#declare cameraX = cameraLookX;\n"
721              "#declare cameraY = cameraLookY;\n"
722              "#declare cameraZ = cameraLookZ - zoom;\n"
# Line 651 | Line 786 | int main(argc, argv)
786              "// declare the periodic box macro\n"
787              "//************************************************************\n"
788              "\n"
789 <            "#macro makePeriodicBox( lengthX, lengthY, lengthZ )\n"
789 >            "#macro makePeriodicBox( bx1, by1, bz1, bx2, by2, bz2, bx3, by3, bz3 )\n"
790              "\n"
791 <            "  #local addX = lengthX / 2.0;\n"
792 <            "  #local addY = lengthY / 2.0;\n"
793 <            "  #local addZ = lengthZ / 2.0;\n"
791 >            "  #local bcx = (bx1 + bx2 + bx3) / 2.0;\n"
792 >            "  #local bcy = (by1 + by2 + by3) / 2.0;\n"
793 >            "  #local bcz = (bz1 + bz2 + bz3) / 2.0;\n"
794 >            "\n"
795 >            "  #local pAx = boxCenterX - bcx;\n"
796 >            "  #local pAy = boxCenterY - bcy;\n"
797 >            "  #local pAz = boxCenterZ - bcz;\n"
798 >            "  #local pBx = boxCenterX + bx1 - bcx;\n"
799 >            "  #local pBy = boxCenterY + by1 - bcy;\n"
800 >            "  #local pBz = boxCenterZ + bz1 - bcz;\n"
801 >            "  #local pCx = boxCenterX + bx2 - bcx;\n"
802 >            "  #local pCy = boxCenterY + by2 - bcy;\n"
803 >            "  #local pCz = boxCenterZ + bz2 - bcz;\n"
804 >            "  #local pDx = boxCenterX + bx3 - bcx;\n"
805 >            "  #local pDy = boxCenterY + by3 - bcy;\n"
806 >            "  #local pDz = boxCenterZ + bz3 - bcz;\n"
807 >            "  #local pEx = boxCenterX + bx1 + bx2 - bcx;\n"
808 >            "  #local pEy = boxCenterY + by1 + by2 - bcy;\n"
809 >            "  #local pEz = boxCenterZ + bz1 + bz2 - bcz;\n"
810 >            "  #local pFx = boxCenterX + bx1 + bx3 - bcx;\n"
811 >            "  #local pFy = boxCenterY + by1 + by3 - bcy;\n"
812 >            "  #local pFz = boxCenterZ + bz1 + bz3 - bcz;\n"
813 >            "  #local pGx = boxCenterX + bx2 + bx3 - bcx;\n"
814 >            "  #local pGy = boxCenterY + by2 + by3 - bcy;\n"
815 >            "  #local pGz = boxCenterZ + bz2 + bz3 - bcz;\n"
816 >            "  #local pHx = boxCenterX + bx1 + bx2 + bx3 - bcx;\n"
817 >            "  #local pHy = boxCenterY + by1 + by2 + by3 - bcy;\n"
818 >            "  #local pHz = boxCenterZ + bz1 + bz2 + bz3 - bcz;\n"
819 >            "\n"
820 >            "  #if(ROTATE)\n"
821 >            "    #local pAx_new = rotatePointX + A11 * (pAx-rotatePointX) + A12 * (pAy-rotatePointY) + A13 * (pAz-rotatePointZ);\n"
822 >            "    #local pAy_new = rotatePointY + A21 * (pAx-rotatePointX) + A22 * (pAy-rotatePointY) + A23 * (pAz-rotatePointZ);\n"
823 >            "    #local pAz_new = rotatePointZ + A31 * (pAx-rotatePointX) + A32 * (pAy-rotatePointY) + A33 * (pAz-rotatePointZ);\n"
824 >            "\n"
825 >            "    #local pBx_new = rotatePointX + A11 * (pBx-rotatePointX) + A12 * (pBy-rotatePointY) + A13 * (pBz-rotatePointZ);\n"
826 >            "    #local pBy_new = rotatePointY + A21 * (pBx-rotatePointX) + A22 * (pBy-rotatePointY) + A23 * (pBz-rotatePointZ);\n"
827 >            "    #local pBz_new = rotatePointZ + A31 * (pBx-rotatePointX) + A32 * (pBy-rotatePointY) + A33 * (pBz-rotatePointZ);\n"
828 >            "\n"
829 >            "    #local pCx_new = rotatePointX + A11 * (pCx-rotatePointX) + A12 * (pCy-rotatePointY) + A13 * (pCz-rotatePointZ);\n"
830 >            "    #local pCy_new = rotatePointY + A21 * (pCx-rotatePointX) + A22 * (pCy-rotatePointY) + A23 * (pCz-rotatePointZ);\n"
831 >            "    #local pCz_new = rotatePointZ + A31 * (pCx-rotatePointX) + A32 * (pCy-rotatePointY) + A33 * (pCz-rotatePointZ);\n"
832 >            "\n"
833 >            "    #local pDx_new = rotatePointX + A11 * (pDx-rotatePointX) + A12 * (pDy-rotatePointY) + A13 * (pDz-rotatePointZ);\n"
834 >            "    #local pDy_new = rotatePointY + A21 * (pDx-rotatePointX) + A22 * (pDy-rotatePointY) + A23 * (pDz-rotatePointZ);\n"
835 >            "    #local pDz_new = rotatePointZ + A31 * (pDx-rotatePointX) + A32 * (pDy-rotatePointY) + A33 * (pDz-rotatePointZ);\n"
836 >            "\n"
837 >            "    #local pEx_new = rotatePointX + A11 * (pEx-rotatePointX) + A12 * (pEy-rotatePointY) + A13 * (pEz-rotatePointZ);\n"
838 >            "    #local pEy_new = rotatePointY + A21 * (pEx-rotatePointX) + A22 * (pEy-rotatePointY) + A23 * (pEz-rotatePointZ);\n"
839 >            "    #local pEz_new = rotatePointZ + A31 * (pEx-rotatePointX) + A32 * (pEy-rotatePointY) + A33 * (pEz-rotatePointZ);\n"
840 >            "\n"
841 >            "    #local pFx_new = rotatePointX + A11 * (pFx-rotatePointX) + A12 * (pFy-rotatePointY) + A13 * (pFz-rotatePointZ);\n"
842 >            "    #local pFy_new = rotatePointY + A21 * (pFx-rotatePointX) + A22 * (pFy-rotatePointY) + A23 * (pFz-rotatePointZ);\n"
843 >            "    #local pFz_new = rotatePointZ + A31 * (pFx-rotatePointX) + A32 * (pFy-rotatePointY) + A33 * (pFz-rotatePointZ);\n"
844 >            "\n"
845 >            "    #local pGx_new = rotatePointX + A11 * (pGx-rotatePointX) + A12 * (pGy-rotatePointY) + A13 * (pGz-rotatePointZ);\n"
846 >            "    #local pGy_new = rotatePointY + A21 * (pGx-rotatePointX) + A22 * (pGy-rotatePointY) + A23 * (pGz-rotatePointZ);\n"
847 >            "    #local pGz_new = rotatePointZ + A31 * (pGx-rotatePointX) + A32 * (pGy-rotatePointY) + A33 * (pGz-rotatePointZ);\n"
848 >            "\n"
849 >            "    #local pHx_new = rotatePointX + A11 * (pHx-rotatePointX) + A12 * (pHy-rotatePointY) + A13 * (pHz-rotatePointZ);\n"
850 >            "    #local pHy_new = rotatePointY + A21 * (pHx-rotatePointX) + A22 * (pHy-rotatePointY) + A23 * (pHz-rotatePointZ);\n"
851 >            "    #local pHz_new = rotatePointZ + A31 * (pHx-rotatePointX) + A32 * (pHy-rotatePointY) + A33 * (pHz-rotatePointZ);\n"
852 >            "\n"
853 >            "  #else\n"
854 >            "    #local pAx_new = pAx;"
855 >            "    #local pAy_new = pAy;"
856 >            "    #local pAz_new = pAz;"
857 >            "\n"
858 >            "    #local pBx_new = pBx;"
859 >            "    #local pBy_new = pBy;"
860 >            "    #local pBz_new = pBz;"
861 >            "\n"
862 >            "    #local pCx_new = pCx;"
863 >            "    #local pCy_new = pCy;"
864 >            "    #local pCz_new = pCz;"
865 >            "\n"
866 >            "    #local pDx_new = pDx;"
867 >            "    #local pDy_new = pDy;"
868 >            "    #local pDz_new = pDz;"
869 >            "\n"
870 >            "    #local pEx_new = pEx;"
871 >            "    #local pEy_new = pEy;"
872 >            "    #local pEz_new = pEz;"
873 >            "\n"
874 >            "    #local pFx_new = pFx;"
875 >            "    #local pFy_new = pFy;"
876 >            "    #local pFz_new = pFz;"
877 >            "\n"
878 >            "    #local pGx_new = pGx;"
879 >            "    #local pGy_new = pGy;"
880 >            "    #local pGz_new = pGz;"
881 >            "\n"
882 >            "    #local pHx_new = pHx;"
883 >            "    #local pHy_new = pHy;"
884 >            "    #local pHz_new = pHz;"
885              "\n"
886 +            "  #end\n"
887 +            "  #local pAx = pAx_new;"
888 +            "  #local pAy = pAy_new;"
889 +            "  #local pAz = pAz_new;"
890 +            "\n"                    
891 +            "  #local pBx = pBx_new;"
892 +            "  #local pBy = pBy_new;"
893 +            "  #local pBz = pBz_new;"
894 +            "\n"                    
895 +            "  #local pCx = pCx_new;"
896 +            "  #local pCy = pCy_new;"
897 +            "  #local pCz = pCz_new;"
898 +            "\n"                    
899 +            "  #local pDx = pDx_new;"
900 +            "  #local pDy = pDy_new;"
901 +            "  #local pDz = pDz_new;"
902 +            "\n"                    
903 +            "  #local pEx = pEx_new;"
904 +            "  #local pEy = pEy_new;"
905 +            "  #local pEz = pEz_new;"
906 +            "\n"                    
907 +            "  #local pFx = pFx_new;"
908 +            "  #local pFy = pFy_new;"
909 +            "  #local pFz = pFz_new;"
910 +            "\n"                    
911 +            "  #local pGx = pGx_new;"
912 +            "  #local pGy = pGy_new;"
913 +            "  #local pGz = pGz_new;"
914 +            "\n"                    
915 +            "  #local pHx = pHx_new;"
916 +            "  #local pHy = pHy_new;"
917 +            "  #local pHz = pHz_new;"
918 +            "\n"
919              "  #local colorR = 0.90;\n"
920              "  #local colorG = 0.91;\n"
921              "  #local colorB = 0.98;\n"
# Line 665 | Line 924 | int main(argc, argv)
924              "\n"
925              "  // 1\n"
926              "  cylinder{\n"
927 <            "    < boxCenterX-addX, boxCenterY-addY, boxCenterZ-addZ >,\n"
928 <            "    < boxCenterX-addX, boxCenterY+addY, boxCenterZ-addZ >,\n"
927 >            "    < pAx, pAy, pAz >,\n"
928 >            "    < pBx, pBy, pBz >,\n"
929              "    pipeWidth\n"
930              "    texture{\n"
931              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 682 | Line 941 | int main(argc, argv)
941              "\n"
942              "  // 2\n"
943              "  cylinder{\n"
944 <            "    < boxCenterX-addX, boxCenterY-addY, boxCenterZ+addZ >,\n"
945 <            "    < boxCenterX-addX, boxCenterY+addY, boxCenterZ+addZ >,\n"
944 >            "    < pAx, pAy, pAz >,\n"
945 >            "    < pCx, pCy, pCz >,\n"
946              "    pipeWidth\n"
947              "    texture{\n"
948              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 699 | Line 958 | int main(argc, argv)
958              "\n"
959              "  // 3\n"
960              "  cylinder{\n"
961 <            "    < boxCenterX+addX, boxCenterY-addY, boxCenterZ-addZ >,\n"
962 <            "    < boxCenterX+addX, boxCenterY+addY, boxCenterZ-addZ >,\n"
961 >            "    < pAx, pAy, pAz >,\n"
962 >            "    < pDx, pDy, pDz >,\n"
963              "    pipeWidth\n"
964              "    texture{\n"
965              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 716 | Line 975 | int main(argc, argv)
975              "\n"
976              "  // 4\n"
977              "  cylinder{\n"
978 <            "    < boxCenterX+addX, boxCenterY-addY, boxCenterZ+addZ >,\n"
979 <            "    < boxCenterX+addX, boxCenterY+addY, boxCenterZ+addZ >,\n"
978 >            "    < pBx, pBy, pBz >,\n"
979 >            "    < pEx, pEy, pEz >,\n"
980              "    pipeWidth\n"
981              "    texture{\n"
982              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 733 | Line 992 | int main(argc, argv)
992              "\n"
993              "  // 5\n"
994              "  cylinder{\n"
995 <            "    < boxCenterX-addX, boxCenterY-addY, boxCenterZ-addZ >,\n"
996 <            "    < boxCenterX-addX, boxCenterY-addY, boxCenterZ+addZ >,\n"
995 >            "    < pCx, pCy, pCz >,\n"
996 >            "    < pEx, pEy, pEz >,\n"
997              "    pipeWidth\n"
998              "    texture{\n"
999              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 750 | Line 1009 | int main(argc, argv)
1009              "\n"
1010              "  // 6\n"
1011              "  cylinder{\n"
1012 <            "    < boxCenterX-addX, boxCenterY-addY, boxCenterZ+addZ >,\n"
1013 <            "    < boxCenterX+addX, boxCenterY-addY, boxCenterZ+addZ >,\n"
1012 >            "    < pBx, pBy, pBz >,\n"
1013 >            "    < pFx, pFy, pFz >,\n"
1014              "    pipeWidth\n"
1015              "    texture{\n"
1016              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 767 | Line 1026 | int main(argc, argv)
1026              "\n"
1027              "  // 7\n"
1028              "  cylinder{\n"
1029 <            "    < boxCenterX+addX, boxCenterY-addY, boxCenterZ+addZ >,\n"
1030 <            "    < boxCenterX+addX, boxCenterY-addY, boxCenterZ-addZ >,\n"
1029 >            "    < pCx, pCy, pCz >,\n"
1030 >            "    < pGx, pGy, pGz >,\n"
1031              "    pipeWidth\n"
1032              "    texture{\n"
1033              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 784 | Line 1043 | int main(argc, argv)
1043              "\n"
1044              "  // 8\n"
1045              "  cylinder{\n"
1046 <            "    < boxCenterX+addX, boxCenterY-addY, boxCenterZ-addZ >,\n"
1047 <            "    < boxCenterX-addX, boxCenterY-addY, boxCenterZ-addZ >,\n"
1046 >            "    < pDx, pDy, pDz >,\n"
1047 >            "    < pGx, pGy, pGz >,\n"
1048              "    pipeWidth\n"
1049              "    texture{\n"
1050              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 801 | Line 1060 | int main(argc, argv)
1060              "\n"
1061              "  // 9\n"
1062              "  cylinder{\n"
1063 <            "    < boxCenterX-addX, boxCenterY+addY, boxCenterZ-addZ >,\n"
1064 <            "    < boxCenterX-addX, boxCenterY+addY, boxCenterZ+addZ >,\n"
1063 >            "    < pDx, pDy, pDz >,\n"
1064 >            "    < pFx, pFy, pFz >,\n"
1065              "    pipeWidth\n"
1066              "    texture{\n"
1067              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 818 | Line 1077 | int main(argc, argv)
1077              "\n"
1078              "  // 10\n"
1079              "  cylinder{\n"
1080 <            "    < boxCenterX-addX, boxCenterY+addY, boxCenterZ+addZ >,\n"
1081 <            "    < boxCenterX+addX, boxCenterY+addY, boxCenterZ+addZ >,\n"
1080 >            "    < pEx, pEy, pEz >,\n"
1081 >            "    < pHx, pHy, pHz >,\n"
1082              "    pipeWidth\n"
1083              "    texture{\n"
1084              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 835 | Line 1094 | int main(argc, argv)
1094              "\n"
1095              "  // 11\n"
1096              "  cylinder{\n"
1097 <            "    < boxCenterX+addX, boxCenterY+addY, boxCenterZ+addZ >,\n"
1098 <            "    < boxCenterX+addX, boxCenterY+addY, boxCenterZ-addZ >,\n"
1097 >            "    < pFx, pFy, pFz >,\n"
1098 >            "    < pHx, pHy, pHz >,\n"
1099              "    pipeWidth\n"
1100              "    texture{\n"
1101              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 852 | Line 1111 | int main(argc, argv)
1111              "\n"
1112              "  // 12\n"
1113              "  cylinder{\n"
1114 <            "    < boxCenterX+addX, boxCenterY+addY, boxCenterZ-addZ >,\n"
1115 <            "    < boxCenterX-addX, boxCenterY+addY, boxCenterZ-addZ >,\n"
1114 >            "    < pGx, pGy, pGz >,\n"
1115 >            "    < pHx, pHy, pHz >,\n"
1116              "    pipeWidth\n"
1117              "    texture{\n"
1118              "      pigment{ rgb < colorR, colorG, colorB > }\n"
# Line 901 | Line 1160 | void usage(){
1160                  "   -h            draw hydrogens\n"
1161                  "   -b            draw bonds\n"
1162                  "   -a            draw atoms\n"
1163 +                "   -v            draw vectors\n"
1164                  "   -p            draw periodic box\n"
1165                  "   -r            regenerate bond\n"
1166                  "   -f <#>        render frame <#> only\n"
# Line 910 | Line 1170 | void usage(){
1170                  program_name);
1171    exit(8);
1172   }
1173 +
1174 + int count_tokens(line, delimiters)
1175 +     /* PURPOSE: RETURN A COUNT OF THE NUMBER OF TOKENS ON THE LINE. */
1176 +     char *line;                /* LINE CONTAINING TOKENS. */
1177 +     char *delimiters;  /* POSSIBLE TOKEN DELIMITERS TO USE. */
1178 + {
1179 +  char *working_line;   /* WORKING COPY OF LINE. */
1180 +  int ntokens;          /* NUMBER OF TOKENS FOUND IN LINE. */
1181 +  char *strtok_ptr;     /* POINTER FOR STRTOK. */
1182 +  
1183 +  strtok_ptr= working_line= strdup(line);
1184 +  
1185 +  ntokens=0;
1186 +  while (strtok(strtok_ptr,delimiters)!=NULL)
1187 +    {
1188 +      ntokens++;
1189 +      strtok_ptr=NULL;
1190 +    }
1191 +  
1192 +  free(working_line);
1193 +  return(ntokens);
1194 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines