I want to get best pitch and roll values. I'm already using that code to get azimut value.
Pitch and roll values seem not be good.
@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;
}
I'm using that code in augmented reality environment (with Jmonkey engine) to move 3d objects depending on phone position :
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);
}
Is something I missed ?
EDIT
Code already in use in app is from this link
It works but I think Sensor.TYPE_ROTATION_VECTOR
is a better way.