1
$\begingroup$

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?

$\endgroup$
4
  • 2
    $\begingroup$ Just add up the distance moved every second. $\endgroup$
    – BowlOfRed
    Jan 1, 2022 at 1:04
  • 1
    $\begingroup$ If your familiar with numerical integration, all those methods apply based on your assumptions for the velocity between the intervals of announcement. $\endgroup$
    – Triatticus
    Jan 1, 2022 at 2:23
  • $\begingroup$ \begin{aligned}V_{i}=a_{i}t+b_{i}\\ X_{i}=\dfrac{a_{i}}{2}t^{2}+b_{i}t\\ t=1\\ X=\sum X_{i}\end{aligned} $\endgroup$
    – Eli
    Jan 1, 2022 at 8:43
  • $\begingroup$ Thank you! Is it correct to assume that a at index i is (v at index i) - (v at index (i-1)) as t is always 1 in my sample data points that I receive? Basically, a is the slope between the data points. Is this correct? Thank you. $\endgroup$
    – MariusVE
    Jan 1, 2022 at 15:53

1 Answer 1

0
$\begingroup$

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}$$

$\endgroup$
2
  • $\begingroup$ Thank you, Farcher! When you say that "the acceleration between equal time interval readings" is constant, you mean to say that the acceleration WITHIN the SECOND is constant or do you mean that the acceleration between EACH second in the data set is constant? I can only assume that the acceleration INSIDE the second is constant: Example: At second 0, v = 10. At second 1, v = 12. I can assume that between second 0 and 1, the acceleration is a constant value of 2. $\endgroup$
    – MariusVE
    Jan 1, 2022 at 16:03
  • $\begingroup$ @MariusVE Consider the3 analysis of the data points as a speed against time graph with the data points connected with straight lines. The area under such a graph as a series of trapeziums is the distance travelled. Your example is correct. $\endgroup$
    – Farcher
    Jan 1, 2022 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.