[Math] Motion with acceleration and deceleration

physics

Stumbled on this while working on a program code to display motion animation. The scenario is, the program will have a function to move a picture from its current position to move right. The program took only 2 variables, which is the travel distance and time to cover the distance. The distance is in pixel and the duration is in frames (in this case, the program runs in $60$ frames / second). Linear movement/zero acceleration is not a problem, the velocity can be found by simply by distance/time. But I'm stuck as the program requires acceleration and deceleration into the motion. The scenario is divided into 3 phases :

  1. The first $30%$ of time will be accelerating, from $0$ slowly increases its speed
  2. The next $40%$ of time, movement has no acceleration, during this, the speed always the same
  3. the last $30%$ of time will be decelerating, speed from the last speed of 2nd phase and slowly decrease its speed until it stops.

I'm not good at physics and what makes this tricky for me is that the only information I have is the total distance to be covered and the time needed to reach that distance. There are no limits on the velocity/acceleration.

Lets take an example: a picture needs to be moved $300$ pixels to the right in $70$ frames.
My question is:

  1. What is the equation to calculate velocity in each frames for each phase in the above scenario?
  2. What is the equation of acceleration in phase $1$ and $3$?

Any help will be appreciated 🙂 Thanks in advance

Best Answer

You need a function $f\colon[0,T]\to[0,d]$ (your specific example has $d=300$ and $T=70$) that looks like $$ f(t)=\begin{cases}\frac12at^2&\text{if }t<\frac3{10}T,\\ vt+x_0&\text{if }\frac3{10}T\le t\le \frac7{10}T,\\ d-\frac12a(T-t)^2&\text{if }t>\frac7{10}T.\end{cases}$$ By symmetry, $vt+x_0=v(t-\frac T2)+\frac d2$. The facts that $f$ and its derivative $f'$ are continouous translate to the conditions $$ a\cdot\frac3{10}T = v$$ and $$ \frac12a\cdot\frac9{100}T^2= -\frac15vT+\frac d2.$$ From this we find $$ a=\frac{200}{21}\cdot \frac d{T^2}$$ and $$v = \frac{20}{7}\cdot \frac dT.$$

Remark: Spline interpolation of the coordinates offsets may be a good and fast alternative.