title: How to calculate distance based on phone acceleration
body: <p>I want to build something like this but using an android phone: <a href="http://www.youtube.com/watch?v=WOt9mb5QqRs" rel="noreferrer">http://www.youtube.com/watch?v=WOt9mb5QqRs</a></p>
  
  <p>I've already built an app that sends sensor information via socket (still looking for a good websocket implementation for android). I intend to use that information to interact with a web app, so for example i would be able to move an image based on the phone movement.
  The problem is that I tried to calculate distance based on the accelerometer data but the results are really bad. I wonder if anyone could help me with the correct equation, but first of all, is it possible to do this?</p>
  
  <p>Till now I'm using the following equations:</p>
  
  <p><code>velocity = acceleration * time;</code></p>
  
  <p><code>distance = velocity * time + (acceleration * time^2) / 2;</code></p>
  
  <p>then I translate distance from meters per second to pixels based on monitor screen resolution.</p>
  
  <p>that's calculated with javascript in the browser every time i receive sensor data, which is every ~80ms.</p>