Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Remember a short history of position, going back a few seconds. 5 seconds should give you a reasonably accurate result that updates fairly quickly...</p> <pre><code>// delay is the time difference between the 2 samples you have delay = 5; // 5 second delay // figure out how far along x and y we have moved since last time dx = newx - oldx; dy = newy - oldy; // distance travelled distance = sqrt(dx*dx + dy*dy); // find the speed. if the positions were measured in metres and the time in seconds // this will be the average speed in metres per second, over the last 5 seconds speed = distance / delay; </code></pre> <p>The longer you can wait between samples (eg, if you keep the last 30 position samples and use a 30 second delay), the more stable your answer will be (ie, the less noisy it will be), but the slower it will be to react to any changes in speed.</p> <p>Why do you need to add this delay stuff? well, the GPS unit in your phone probably isn't very accurate. If you are standing still, the position it returns each second might wobble about a fair bit. This wobble noise will make it look like you are sprinting randomly around the room and might cause you to report a moderately high speed, even though you're not moving at all. The solution I have listed will not really help when you are standing still, as the result from 30 seconds ago will be just as wrong as the position from 1 second ago. What you really need to do is average the position over a while, then compare that to the average position from a slightly earlier time. eg...</p> <p>Take 10 samples of position and average them. This is position 1.<br> Take another 10 samples and average them. This is position 2.<br> Use these 2 positions with the code above to get the speed.</p> <p>Again, the more samples you can take, the more accurate and stable your positions will become, but this will make your speed measurement less responsive.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload