Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

to_com.C

Go to the documentation of this file.
00001 
00008 
00009 //   version 1:  Dec 1992   Piet Hut
00010 
00011 #include "dyn.h"
00012 
00013 #ifndef TOOLBOX
00014 
00015 void dyn::to_com()
00016 {
00017     vector com_pos;
00018     vector com_vel;
00019 
00020     compute_com(this, com_pos, com_vel);
00021 
00022 //    pos += com_pos;   // Note: The position and velocity of the root node
00023 //    vel += com_vel;   //       have no particular dynamical significance.
00024                         //       They are not integrated forward in time,
00025                         //       and play no role in any integrator.
00026 
00027     for_all_daughters(dyn, this, bj) {
00028         bj->pos -= com_pos;
00029         bj->vel -= com_vel;
00030     }
00031 
00032     // Correct entries in top-level dyn story.
00033 
00034     com_pos = vector(0,0,0);
00035     com_vel = vector(0,0,0);
00036 
00037     putvq(get_dyn_story(), "com_pos", com_pos);
00038     putvq(get_dyn_story(), "com_vel", com_vel);
00039 }
00040 
00041 #else
00042 
00043 main(int argc, char ** argv)
00044 {
00045     bool  c_flag = FALSE;
00046     char  *comment;
00047 
00048     check_help();
00049 
00050     extern char *poptarg;
00051     int c;
00052     char* param_string = "c:";
00053 
00054     while ((c = pgetopt(argc, argv, param_string)) != -1)
00055         switch(c) {
00056 
00057             case 'c': c_flag = TRUE;
00058                       comment = poptarg;
00059                       break;
00060             case '?': params_to_usage(cerr, argv[0], param_string);
00061                       get_help();
00062                       exit(1);
00063         }            
00064 
00065     dyn *b;
00066 
00067     while (b = get_dyn(cin)) {
00068 
00069         if (c_flag == TRUE)
00070             b->log_comment(comment);
00071         b->log_history(argc, argv);
00072 
00073         b->to_com();
00074         put_dyn(cout, *b);      
00075         delete b;
00076     }
00077 }
00078 
00079 #endif
00080 
00081 // endof: to_com
00082 

Generated at Sun Feb 24 09:57:19 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001