title: Interpolate between 2 GPS locations based on walking speed
body: <h3>Problem:</h3>
  
  <hr>
  
  <p>Given two locations:</p>
  
  <p><strong>L<sub>1</sub> = (latitude<sub>1</sub>, longitude<sub>1</sub>, timestamp<sub>1</sub>)</strong>, <strong>L<sub>2</sub> = (latitude<sub>2</sub>, longitude<sub>2</sub>, timestamp<sub>2</sub>)</strong>,</p>
  
  <p>and a configurable, but constant, movement speed:</p>
  
  <p><strong>v = 1.39 meters per second</strong> (for instance).</p>
  
  <p>How can we interpolate between these two locations to estimate a users location as he travels from <strong>L<sub>1</sub></strong> to <strong>L<sub>2</sub></strong>?</p>
  
  <hr>
  
  <p>I have been searching for solutions to this problem and so far I have found, that for small distances (away from the poles) linear interpolation can be used. So, I looked up <a href="https://en.wikipedia.org/wiki/Linear_interpolation" rel="noreferrer">linear interpolation</a> on Wikipedia and found this:</p>
  
  <pre><code>// Imprecise method which does not guarantee v = v1 when t = 1,
  // due to floating-point arithmetic error.
  float lerp(float v0, float v1, float t) {
      return v0 + t*(v1-v0);
  }
  </code></pre>
  
  <p>So I am thinking of using this lerp function to interpolate latitude and longitude between <strong>L<sub>1</sub></strong> and <strong>L<sub>2</sub></strong>. That was the easy part. How do I calculate <strong>t</strong>? I'm guessing I have to calculate some time deltas, but how do I factor in the movement speed?</p>
  
  <hr>
  
  <h3>Edit:</h3>
  
  <p>I'm testing various methods for collecting GPS-locations. For this purpose, I am recording waypoint-locations throughout a walk. I need to interpolate between these waypoints, using the movement speed, to estimate my position along the walk. Then I can compare my results to the estimates to see how well they are faring.</p>
  
  <p>Example:</p>
  
  <p><a href="https://i.stack.imgur.com/aGDdh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/aGDdh.png" alt="map"></a></p>