title: Android: Determining the angle of tilt using only accelerometers
body: <p>I am trying to compute the angle of a leg instantaneously regarding an initial position using accelerometer readings.</p>
  
  <p>As I approached this, I decided I needed to record an averaged gravity vector and compute some angle between my current reading and that.</p>
  
  <p>Theoretically it seems plausible: the reading of gravity is different on each position of the leg, so in stationary positions the readings should converge to a vector I can use to find the angular displacement of the leg, with respect to the reading at the start.</p>
  
  <p>However, I have tried several combinations: the angle between both vectors using only the Z and Y components (using <a href="http://www.wikihow.com/Find-the-Angle-Between-Two-Vectors" rel="nofollow">this</a>); compute the difference vector between both gravity and current, and do atan2(dY,SQRT(dX^2+dZ^2)); compute atan2(dY,dz)... (where dY and dZ are the subtraction of the current and gravity vector for the Y and Z components, respectively)</p>
  
  <p>None of these solutions seem to be working, so I am wondering if I can even do this.</p>
  
  <p>Does anyone have a solution for this?</p>