Android - SensorManager weird getOrientation behavior

I need to get the orientation of my phone. At the moment, I wrote this:

public void onSensorChanged(SensorEvent event) {
  switch (event.sensor.getType()){
  case Sensor.TYPE_MAGNETIC_FIELD:
    this.mag_vals = event.values.clone();
    this.sensorReady = true;
    break;
  case Sensor.TYPE_ACCELEROMETER:
    this.acc_vals = event.values.clone();
    break;
  }
  if (this.mag_vals != null && this.acc_vals != null && this.sensorReady) {
    this.sensorReady = false;
    float[] R = new float[ProjectConstants.SIZE_MATRIX];
    float[] I = new float[ProjectConstants.SIZE_MATRIX];
    SensorManager.getRotationMatrix(R, I, this.acc_vals, this.mag_vals);

    SensorManager.getOrientation(R, this.actual_orientation);
    ...  

This code allows me to get the orientation of the phone if I leave the phone on a flat surface and I rotate it on the surface.

What I did not understand is why, if I move the phone up, the value this.actual_orientation[0], which is rotation on the zed axis, as described [here] [1], the value increases, although there was no rotation.

Did anyone know what was going on?

EDIT

Another weird thing.

, , . ( ) , , . , . ( ) i-phone compass, !

, , , Android, ! , ...

.

[1]: http://developer.android.com/reference/android/hardware/SensorManager.html#getOrientation(float[], float [])

+5
2

, , . , , . .

, .

+4

, , getOrientation. , , "", , 90 -90. , , remapCoordinateSystem getOrientation.

+1

All Articles