我正在读取手机的方向值,方位角和滚动数据非常好,因为它们是 -180 到 180,但是我在俯仰方面有问题,因为只有当我将手机从 0 度旋转到 360 度时它是 -90 到 90程度。
SensorManager.getRotationMatrixFromVector(mRotationMatrix, event.values);
SensorManager.getOrientation(mRotationMatrix, orientationVals);
float azimuth = (float)Math.toDegrees(orientationVals[0]);
float pitch = (float)Math.toDegrees(orientationVals[1]);
float roll = (float)Math.toDegrees(orientationVals[2]);
float deltaX = Math.abs(mLastOrientation[0] - azimuth);
float deltaY = Math.abs(mLastOrientation[1] - pitch);
float deltaZ = Math.abs(mLastOrientation[2] - roll);
if (deltaX < ORIENTATIONNOISE) azimuth = mLastOrientation[0];
if (deltaY < ORIENTATIONNOISE) pitch = mLastOrientation[1];
if (deltaZ < ORIENTATIONNOISE) roll = mLastOrientation[2];
mLastOrientation[0] = azimuth;
mLastOrientation[1] = pitch;
mLastOrientation[2] = roll;
谁能帮忙。谢谢