title: Gravity Compensation in Accelerometer Data
body: <p>Given an Accelerometer with 9 DOF (Accelerometer, Gyroscope and Magnetometer) I want to remove/compensate the effect of the gravity in accelerometer reading (Accelerometer can rotate freely). The sensor gives the orientation in quaternion representation relative to a (magnetic)north, west and up reference frame. </p>
  
  <p>I found this <a href="http://www.varesano.net/blog/fabio/simple-gravity-compensation-9-dom-imus" rel="noreferrer">http://www.varesano.net/blog/fabio/simple-gravity-compensation-9-dom-imus</a>
  but couldn't understand the basis for the given equation. </p>
  
  <p>How could I achieve this given above information?</p>