[Math] Bezier curve and deceleration

bezier-curvephysics

I have a question regarding calculation of a cubic Bezier curve. I'm programming an app where in there's continuous straight line motion of a vehicle at a constant speed. (Let's call it $u$). When the user taps a button, the vehicle decelerates at a constant rate and finally stops after a time period $t$ and moving a certain distance $d$.

However, due to restrictions of the system I'm coding in, I'm supposed to model this deceleration using a Bezier curve. The $y$ axis of the Bezier curve would be distance moved, while the $x$ axis is time. The system only lets me modify the 2 control points (or guide points) of the curve. The initial point is set to $(0,0)$ and the final point is set to $(1,1)$.

At this point, I already know the value of $t$, the value of $d$, and also the value of $u$. Final velocity $v = 0$. Using this I can even calculate the deceleration rate as $a = (v-u)/t$ since deceleration is linear. However, the system only takes the two middle points of the Bezier curve to model this deceleration.

Could I have some help in using the values I have to get the Bezier points?

Note: The bezier curve is normalized. the initial point is set to (0,0) and the final to (1,1). So it assumes that the deceleration animation starts at x = 0 (time = 0) and ends at x = 1 (time = t), and y = 0 when distance moved = 0, and y = 1 when distance moved = d

Best Answer

I'll keep using your notation $t$ for time, $d$ for distance, $u$ for initial velocity, $v$ for final velocity, and $a$ for acceleration. Note that $a$ will be a negative constant.

The vehicle stops when $v=u+at=0$, i.e. at $t_f=-\frac ua$. The distance covered is $d=ut+\frac 12at^2$, which at the stopping point will be $d_f=-\frac{u^2}{2a}$. If we then scale these onto a $x$-$y$ graph from $(0,0)$ to $(1,1)$ by letting $x=\frac t{t_f}$ and $y=\frac d{d_f}$ the equation $d=ut+\frac 12at^2$ becomes

$$y=2x-x^2$$

Note that you get the same equation in $x$ and $y$ after scaling, no matter what the values of $t$, $d$, and $u$ are. That makes your job simpler but more boring: you need to approximate the parabola $y=2x-x^2$ for $0\le x\le 1$ by a Bezier curve.

(I made a mistake in my first analysis, corrected brilliantly by @fang in a comment. The following is my corrected analysis.)

You get that curve by using the cubic Bezier curve with starting point $P_0(0,0)$, first control point $P_1(\frac 13,\frac 23)$, second control point $P_2(\frac 23,1)$, and endpoint $P_3(1,1)$. This reproduces the desired parabola exactly. In fact, if you slow down the drawing by increasing the Bezier curve's parameter at a constant rate, the moving point will be at each correct place on the graph at the correct time.