I have a home trainer that is connected to an application that I am writing which needs to calculate a distance traveled given the speeds that the trainer is sending.
As such, every second, the trainer sends the instantaneous speed of the rider.
Example:
At Second 0: 10 km/h
At Second 1: 15 km/h
At Second 2: 12 km/h
..
Again, all that I receive are the speeds.
Each second, I need to calculate the total distance traveled.
Example: At second 1, I should know how far the rider has traveled (knowing the speeds from Second 0 and Second 1). At second 2, again, I would need to know how far the rider has traveled (knowing the speed at Second 1 and at Second 2) and so on.
What would be the correct way to at least approximate it?
Best Answer
I think that a simple way is to assume that the acceleration between equal time interval readings is constant which, I think, is your suggestion?
Thus the average speed between time $t=i$ and $t=i+1$ is $$\dfrac{v_{\rm i}+v_{\rm i+1}}{2}$$ and so the distance travelled in this time interval is $$\dfrac{v_{\rm i}+v_{\rm i+1}}{2}\times ((i+1)-i) = \dfrac{v_{\rm i}+v_{\rm i+1}}{2}$$