2

私はAndroidのTYPE_ROTATION_VECTORセンサーを使用して、x、y、zの周りの回転を決定し、アプリケーションでこれらの測定値を特定の方法で使用しています。しかし、電話をX軸を中心に回転させると、ロール値(Yを中心とした回転)も変化します。そして、私はそれを望んでいません。Xを中心に回転するときのロールの変化を無視するにはどうすればよいですか?これが私のコードの一部です

private final float[] mRotationMatrix = new float[16];
private float[] orientationVals = new float[3];

if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {

             SensorManager.getRotationMatrixFromVector(
                     mRotationMatrix , event.values);
             SensorManager.getOrientation(mRotationMatrix, orientationVals);

             azimuthVal =  (Math.round((Math.toDegrees(orientationVals[0]))*100.0)/100.0);
             pitchVal= (Math.round((Math.toDegrees(orientationVals[1]))*100.0)/100.0);
             rollVal = (Math.round((Math.toDegrees(orientationVals[2]))*100.0)/100.0);
             }
4

0 に答える 0