00001
00008
00009
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
00023
00024
00025
00026
00027 for_all_daughters(dyn, this, bj) {
00028 bj->pos -= com_pos;
00029 bj->vel -= com_vel;
00030 }
00031
00032
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
00082