You asked for a demo posted to the forums on Twitter, so here it is.
The important bit is this function:
const calcAccel = (x, v, maxA, dt) => {
if(dt === 0) return 0;
const signX = (x < 0)?-1:1;
const a = signX * (Math.sqrt(Math.abs(1 + (2 * x) / (maxA * dt * dt))) * maxA - (v * signX) / dt - maxA);
return Math.min(maxA, Math.max(-maxA, a));
}
It takes a distance, velocity, maximum acceleration and time delta and returns the acceleration that needs to be applied to reach the destination and stop there given acceleration and velocity constraints.
The attractive part of this is that the destination can be changed at will and the formula will always work out. And if the acceleration and velocity constraints are such as to prevent exactly stopping on the target, it will simply overshoot and correct.
I've come to this after first trying to apply tweening to my problem. But perhaps this can be wrapped into a custom tween.
Basic demo: http://codepen.io/killroy/pen/jyaKYo
Real-world demo: http://codepen.io/killroy/pen/MJvGLW
I've developed it for various applications in an RTS game (such as turning turrets and ship motion), but I constantly find other applications for it.
Cheers!