title: Get stabilized pitch and roll values
body: <p>I want to get best pitch and roll values.
  I'm already using that code to get azimut value. </p>
  
  <p>Pitch and roll values seem not be good.</p>
  
  <pre><code>@Override
      public void onSensorChanged(SensorEvent event) {
  
          switch (event.sensor.getType()) {
  
              case Sensor.TYPE_ROTATION_VECTOR:
                  // calculate th rotation matrix
                  SensorManager.getRotationMatrixFromVector(rMat, event.values);
  
                  float[] data = SensorManager.getOrientation(rMat, orientation);
  
                  Log.i(TAG, "NEW pitch?="+data[1]+" roll="+data[2]);
  
                  // do something with data
  
                  break;
          }
  </code></pre>
  
  <p>I'm using that code in augmented reality environment (with Jmonkey engine) to move 3d objects depending on phone position :</p>
  
  <pre><code>public void updateRotationFused(float pitch, float roll) {
      //pitch: cams x axis roll: cams y axisheading: cams z axis
      mRotXYZQ.fromAngles(pitch + FastMath.HALF_PI , roll - FastMath.HALF_PI, 0);
      mCurrentCamRotationFused = mInitialCamRotation.mult(mRotXYZQ);
  }
  </code></pre>
  
  <p>Is something I missed ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Code already in use in app is from this <a href="https://github.com/TKJElectronics/BalanduinoAndroidApp/blob/master/src/com/tkjelectronics/balanduino/SensorFusion.java" rel="nofollow" title="link">link</a> </p>
  
  <p>It works but I think <code>Sensor.TYPE_ROTATION_VECTOR</code> is a better way.</p>