Chris, I'm trying to understand velocity calculation, and I can't come up with current formula, I ended up with this, could you please tell what am I missing?
Thanks in advance, Alex. void tcRunCycle(TP_STRUCT *tp, TC_STRUCT *tc, double *v, int *on_final_decel) { - double discr, maxnewvel, newvel, newaccel=0; + double dtg, maxnewvel, newvel, newaccel=0; if(!tc->blending) tc->vel_at_blend_start = tc->currentvel; - - discr = 0.5 * tc->cycle_time * tc->currentvel - (tc->target - tc->progress); - if(discr > 0.0) { + dtg = tc->target - tc->progress; + // compare with disance over cycle with constant desceleration to 0. + if(dtg <= tc->currentvel * tc->cycle_time / 2.0) // should never happen: means we've overshot the target newvel = maxnewvel = 0.0; - } else { - discr = 0.25 * pmSq(tc->cycle_time) - 2.0 / tc->maxaccel * discr; - newvel = maxnewvel = -0.5 * tc->maxaccel * tc->cycle_time + - tc->maxaccel * pmSqrt(discr); + else { + // time to cover dtg with maxaccel and zero end speed + double time = pmSqrt(2.0 * dtg / tc->maxaccel); + newvel = maxnewvel = tc->maxaccel * (time - tc->cycle_time); } ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers